What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

Just some basic docker commands:



Add user to docker group (for non-root docker admin)

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Manage images

List images

docker image ls

Remove images

Remove all dangling images (e.g. those that are not tagged or referenced by a container):

docker image prune

Remove all images not currently in-use by an existing container:

docker image prune -a

Update a docker image

docker pull <image>

Where <image> is the docker image, e.g. "prom/prometheus".

Update all docker images at once

docker images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 docker pull 

Manage containers

View container logs

To output and follow logs of a container use the -f or --follow flags:

docker logs -f <container>

To show extra details (such as env variables etc.) use the --details flag:

docker logs --details <container>

List containers

Show running:

docker container ls

Show all:

docker container ls --all

Start / stop / restart container

docker <start|stop|restart> <container>

Remove container

docker rm <container>

The below will stop and remove (delete) a container

docker rm -f <container>

List container port mappings 

docker port <container>

Copy file(s) from container to host

docker cp <container>:/file/path/within/container /host/path/target

Interactively log into container with bash

docker exec -it <container> /bin/bash


This will delete all stopped containers, all networks not used, all dangling images, and all build cache:

docker system prune


  1. https://docs.docker.com/
  2. https://www.googlinux.com/update-all-docker-images/index.html
  3. https://stackoverflow.com/questions/22049212/copying-files-from-docker-container-to-host