Cheat Sheets Practical By Samson Tanimawo, PhD Published Jun 2, 2025 4 min read

Docker Cheatsheet

Top commands.

Building images

docker build -t myapp:latest .: builds from Dockerfile in current directory.

docker build --target=builder -t myapp:builder .: multi-stage builds; specific target.

docker build --platform=linux/amd64,linux/arm64: multi-platform images. Useful for ARM-x86 mixed fleets.

Running containers

docker run -d -p 8080:80 nginx: detached, port mapping. Standard for service containers.

docker run --rm -it ubuntu bash: interactive, removed on exit. Useful for one-off debugging.

docker run -v /host:/container myapp: bind mount. -v name:/container for named volumes.

Inspecting containers

docker ps -a: all containers including stopped. -a shows ones that exited.

docker logs --tail 100 -f container-name: follow logs.

docker exec -it container-name sh: shell into a running container. Don't use docker run for this.

Managing images

docker images: lists local images.

docker pull image:tag: pulls without running.

docker rmi image:tag: removes local image. -f to force.

Cleaning up

docker system prune -a: removes unused images, stopped containers, networks, volumes.

docker volume prune: removes unused volumes specifically.

docker container prune: removes stopped containers.