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
| Command | What it does |
docker build -t app:latest . | Build an image from the Dockerfile in this folder |
docker images | List local images |
docker pull nginx | Download an image from a registry |
docker rmi image | Remove an image |
docker tag app:latest app:v1 | Add a second tag to an image |
Containers
| Command | What it does |
docker run -d -p 8080:80 nginx | Run detached, mapping host 8080 to container 80 |
docker ps / docker ps -a | List running / all containers |
docker exec -it id bash | Open a shell inside a running container |
docker logs -f id | Follow a container's logs |
docker stop id / docker rm id | Stop / remove a container |
docker inspect id | Full JSON detail (network, mounts, env) |
Docker Compose
| Command | What it does |
docker compose up -d | Start all services from compose.yaml, detached |
docker compose down | Stop and remove everything Compose created |
docker compose logs -f web | Follow logs for one service |
docker compose ps | Status of the stack's services |
docker compose build --no-cache | Rebuild 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
| Command | What it does |
docker system df | Show how much disk Docker is using |
docker container prune | Remove all stopped containers |
docker volume prune | Remove unused volumes |
docker system prune -a | Reclaim 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 →