IT Pro Toolkit · Reference

Docker & Compose Cheat Sheet

The container commands you reach for daily — building images, running and inspecting containers, wrangling Compose, and cleaning up the mess Docker leaves behind.

Updated July 2026 · ~5 min read

Docker is easy to start and easy to accumulate cruft with. These are the commands that come up on a real machine — the ones worth knowing without a lookup — grouped by what you're trying to do.

Images

CommandWhat it does
docker build -t app:latest .Build an image from the Dockerfile in this folder
docker imagesList local images
docker pull nginxDownload an image from a registry
docker rmi imageRemove an image
docker tag app:latest app:v1Add a second tag to an image

Containers

CommandWhat it does
docker run -d -p 8080:80 nginxRun detached, mapping host 8080 to container 80
docker ps / docker ps -aList running / all containers
docker exec -it id bashOpen a shell inside a running container
docker logs -f idFollow a container's logs
docker stop id / docker rm idStop / remove a container
docker inspect idFull JSON detail (network, mounts, env)

Docker Compose

CommandWhat it does
docker compose up -dStart all services from compose.yaml, detached
docker compose downStop and remove everything Compose created
docker compose logs -f webFollow logs for one service
docker compose psStatus of the stack's services
docker compose build --no-cacheRebuild images from scratch
The reflex that saves you: docker system prune -a reclaims disk from stopped containers, unused networks, and dangling images. Run it when Docker has quietly eaten 40 GB.

Cleanup

CommandWhat it does
docker system dfShow how much disk Docker is using
docker container pruneRemove all stopped containers
docker volume pruneRemove unused volumes
docker system prune -aReclaim everything not in active use

Get the printable Docker & Compose cheat sheet

The full Docker & Compose Cheat Sheet is a clean one-pager with every command above plus flags, volume and network syntax, and a Dockerfile reference — built for a second monitor. Instant download.

Get the cheat sheet →