Skip to content
docktionary

Docker

CLI reference

Not every flag docker has — the commands that come up constantly, grouped by what they manage.

Images

bash
docker pull <image>                 # download an image
docker build -t <name>:<tag> .       # build from a Dockerfile
docker images                        # list local images
docker history <image>               # show layers
docker tag <image> <new-name>:<tag>  # add another tag
docker push <name>:<tag>             # upload to a registry
docker rmi <image>                   # delete a local image
docker image prune                   # delete dangling images
docker save <image> -o image.tar     # export an image to a tarball
docker load -i image.tar             # import a tarball back into docker

docker save is what the Inspector reads — open a tarball there to see exactly what's in it, layer by layer.

Containers

bash
docker run <image>                   # create and start a container
docker ps / docker ps -a             # running / all containers
docker start|stop|restart <id>
docker rm <id>                       # remove a stopped container
docker logs -f <id>                  # follow logs
docker exec -it <id> sh              # shell into a running container
docker cp <id>:/path ./local         # copy a file out of a container
docker stats                         # live CPU/memory/network usage
docker top <id>                      # processes running inside it
docker diff <id>                     # files added/changed/deleted vs. the image
docker export <id> -o rootfs.tar     # flatten a container's filesystem to a tar

docker export looks like docker save but isn’t the same thing: export flattens a container’s current filesystem into one tar with no layer history or image config, while save preserves an image’s layers and metadata intact — which is also why only save output works with the Inspector.

Volumes & networks

bash
docker volume create|ls|inspect|rm <name>
docker network create|ls|inspect|rm <name>
docker network connect <net> <container>
docker network disconnect <net> <container>

Compose

bash
docker compose up -d        # start the stack in the background
docker compose down          # stop and remove it
docker compose ps
docker compose logs -f <service>
docker compose exec <service> sh
docker compose build          # rebuild images defined with "build:"
docker compose restart <service>

System & cleanup

bash
docker system df              # disk space used by images/containers/volumes
docker system prune           # remove unused containers, networks, build cache
docker system prune -a --volumes  # also remove unused images and volumes
docker info                   # daemon-wide configuration and resource info
docker version                # client and server (daemon) versions

Build

bash
docker build --no-cache -t <name> .        # ignore the layer cache
docker build --build-arg NODE_VERSION=22 .  # pass a build-time ARG
docker build --target <stage> -t <name> .   # build one stage of a multi-stage file

Multi-platform builds, build secrets, cache mounts, and sharing build cache across CI runs are all buildx features — see Buildx.