Cheatsheet
← All cheat sheets

Docker cheat sheet

Docker commands for everyday work, plus Docker Compose. Click a command to copy it.

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
Something not working?

Send feedback

What is it?

The page you’re on, your browser and your screen size are sent along to help us fix it. Never your files or what you typed into the tool.