This cheatsheet contains the most common Docker commands for daily use, focused on managing containers, images, volumes, and Docker Compose. Perfect for developers, sysadmins, and DevOps engineers.
For full documentation, visit: https://docs.docker.com
๐ฆ Container Management
Action |
Command |
Start a container |
docker start <container> |
Stop a container |
docker stop <container> |
Restart a container |
docker restart <container> |
Remove a container |
docker rm <container> |
Force remove |
docker rm -f <container> |
List running containers |
docker ps |
List all containers (including stopped) |
docker ps -a |
View container logs |
docker logs <container> |
Follow container logs |
docker logs -f <container> |
Execute shell inside container |
docker exec -it <container> bash |
Rename a container |
docker rename <old> <new> |
๐งฑ Image Management
Action |
Command |
List images |
docker images |
Remove an image |
docker rmi <image> |
Build image from Dockerfile |
docker build -t <tag> . |
Pull image from Docker Hub |
docker pull <image> |
Push image to registry |
docker push <image> |
Tag an image |
docker tag <image> <new-tag> |
๐ Volumes & Networks
Action |
Command |
List volumes |
docker volume ls |
Remove a volume |
docker volume rm <volume> |
List networks |
docker network ls |
Connect container to a network |
docker network connect <network> <container> |
Disconnect container from a network |
docker network disconnect <network> <container> |
๐ ๏ธ Docker Compose (v2 syntax)
Action |
Command |
Start services |
docker compose up -d |
Stop services |
docker compose down |
Restart services |
docker compose restart |
View logs |
docker compose logs -f |
Restart a specific service |
docker compose restart <service> |
Rebuild containers |
docker compose up --build |
Stop and remove containers, networks, and volumes |
docker compose down -v |
๐งผ Clean-up & Maintenance
Action |
Command |
Remove stopped containers |
docker container prune |
Remove unused volumes |
docker volume prune |
Remove dangling images |
docker image prune |
Clean all unused data (containers, images, networks, volumes) |
docker system prune -a |
๐ง Miscellaneous
Action |
Command |
Show Docker version |
docker version |
Inspect container details |
docker inspect <container> |
Show real-time container stats |
docker stats |
Show disk usage |
docker system df |