Cheatsheet

Docker quick reference

The Docker commands for building, running and cleaning up — the set that covers most local and deploy work.

Images

docker build -t app:latest .Build an image from the Dockerfile in the current directory.
docker imagesList local images.
docker pull node:20-alpineDownload an image from a registry.

Containers

docker run -p 3000:3000 appRun a container and map a port.
docker ps -aList all containers (running and stopped).
docker exec -it <id> shOpen a shell inside a running container.
docker logs -f <id>Follow a container’s logs.

Compose

docker compose up -dStart the whole stack in the background.
docker compose logs -f webFollow logs for one service.
docker compose downStop and remove the stack.

Cleanup

docker system prune -fRemove stopped containers, unused networks and dangling images.
docker volume pruneReclaim space from unused volumes (careful — data).