Docker Cheat Sheets

Cheat sheets for frequently used Docker commands and concepts

3 min read |530 words
May 1, 2026

Docker Images

DescriptionCommand Example
Docker Build
Build an image from a Dockerfiledocker build -t myapp:latest .
Build an image from a Dockerfile with a specific tagdocker build -t myapp:1.0 .
Docker Pull
Pull an image from a registrydocker pull nginx
Pull an image with a specific tagdocker pull nginx:latest
Pull an image from a private registrydocker pull myregistry.com/myapp:latest
Docker Push
Push an image to a registrydocker push myapp:latest
Push an image to a registry with a specific tagdocker push myapp:1.0
Push an image to a private registrydocker push myregistry.com/myapp:latest
Others
List imagesdocker images
Remove an imagedocker rmi myapp:latest
Tag an imagedocker tag myapp:latest myrepo/myapp:latest
Show the history of an imagedocker history myapp:latest

Docker Containers

DescriptionCommand Example
Run a containerdocker run -d -p 80:80 nginx
List running containersdocker ps
Stop a containerdocker stop <container_id>
Remove a containerdocker rm <container_id>
View container logsdocker logs <container_id>

Docker Volumes

DescriptionCommand Example
docker volume createCreate a volume
docker volume lsList volumes
docker volume rmRemove a volume
docker run -vMount a volume to a container

Docker Networks

DescriptionCommand Example
Create a networkdocker network create mynetwork
List networksdocker network ls
Remove a networkdocker network rm mynetwork
Connect a container to a networkdocker run --network mynetwork nginx

Docker Compose

DescriptionCommand Example
Lifecycle Commands
Start services defined in docker-compose.ymldocker compose up
Stop and remove containers, networks, volumesdocker compose down
Stop servicesdocker compose stop
Start servicesdocker compose start
Restart servicesdocker compose restart
Image & Container Management Commands
Build or rebuild servicesdocker compose build
Pull service imagesdocker compose pull
Push service imagesdocker compose push
Remove stopped service containersdocker compose rm
Logging, Execution, and Scaling Commands
List containersdocker compose ps
View output from containersdocker compose logs
Execute a command in a running containerdocker compose exec web ls -l
Execute a command in an interactive shelldocker compose exec -it bash
Scale a servicedocker compose scale web=3
Configuration and Help Commands
Get help on a commanddocker compose help up
Show the Docker Compose version informationdocker compose version
Validate and view the compose filedocker compose config
Run a one-off command on a servicedocker compose run web python manage.py migrate

Docker Swarm

DescriptionCommand Example
Swarm Management Commands
Initialize a swarmdocker swarm init
Join a swarmdocker swarm join --token <token>
Leave a swarmdocker swarm leave
Update swarm configurationdocker swarm update --task-history-limit 5
Display the join token for a swarmdocker swarm join-token worker
Service Management Commands
List swarm servicesdocker service ls
List tasks for a servicedocker service ps <service_name>
Create a new servicedocker service create --name web nginx
Update a servicedocker service update --replicas 3 web
Remove a servicedocker service rm web
Node Management Commands
List swarm nodesdocker node ls
Update a nodedocker node update --availability drain <node_id>
Remove a nodedocker node rm <node_id>

Additional Docker Commands

See the Docker CLI Reference for a complete list of Docker commands and options.