Docker cheat sheet
Docker commands for everyday work, plus Docker Compose. Click a command to copy it.
Nothing matches your search.
Images
- Build an image from the Dockerfile here
- Build with a version tag
- List images
- Download an image
- Upload an image to a registry
- Delete an image
Running containers
- Run in the background, port 8080 on your machine → 80 inside
- Run with a shell, removed when you exit
- Pass an environment variable
- Pass variables from a file
- Share the current folder with the container
Managing containers
- Running containers
- All containers, including stopped
- Stop a container
- Start it again
- Restart
- Delete a stopped container (-f to force)
Inside a container
- Follow a container’s output
- Last 100 lines of output
- Open a shell in a running container
- Copy a file out of a container
- Live CPU and memory use
- All details as JSON
Volumes and networks
- Create a volume for data that should survive
- Use a volume
- List volumes
- Create a network so containers can reach each other by name
- Join a network
Docker Compose
- Start everything in compose.yaml in the background
- Rebuild images, then start
- Stop and remove the containers
- Same, and delete the volumes (data!)
- Follow one service’s output
- Shell in a running service
- Services and their state
Cleaning up
- How much disk Docker uses
- Delete all stopped containers
- Delete images no container uses
- Delete stopped containers, unused networks and dangling images

