💡 Why This Cheat Sheet is Your Must-Read Are you tired of constantly searching for that one Docker command you used last month? This cheat sheet is designed to be your single source of truth for day-to-day and production-grade Docker operations.
This guide provides practical, real-world commands for:
-
Rapid Development: Speed up your local development with efficient image and container management.
-
Production Deployment: Learn the commands for advanced operations like Docker Compose, Volumes, and Networking.
-
Troubleshooting: Quickly debug running containers and manage resources effectively with logs and cleanup commands.
-
Structured Learning: Every command is broken down into a clear Command, Description, and Use Case to maximize your understanding.
Stop Googling, Start Shipping!
- ✔️ Well-organized command categories
- ✔️ Real production use-cases
- ✔️ Clean tables for quick lookup
- ✔️ Beginner-friendly but powerful
- ✔️ Includes Compose, Networks, Volumes, Plugins & Maintenance
- Docker Basics & System Info
- Container Lifecycle
- Images
- Docker Compose
- Volumes
- Registry & Hub
- Networks
- Logs & Debugging
- Cleanup & Maintenance
- Plugin Management
- Useful Resources
| Command | Description | Production Use Case | Example |
|---|---|---|---|
docker --version |
Shows installed Docker version. | Verify environment before deployment. | docker -v |
docker info |
Displays system-wide details (containers, images, drivers). | Debugging host-level issues. | docker info |
docker pull <image> |
Downloads an image from registry. | Retrieve base images for deployment. | docker pull nginx:latest |
docker images |
Lists all local images. | Audit and cleanup. | docker image ls |
docker ps |
Shows running containers. | Check active services quickly. | docker container ls |
docker ps -a |
Shows all containers (including stopped). | Debug recently failed services. | docker container ls -a |
docker run <options> <image> |
Creates + starts container. | Deploying a service. | docker run -d -p 8080:80 nginx |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker start <id> |
Starts a stopped container. | Restart service after maintenance. | docker start web_app |
docker stop <id> |
Gracefully stops container. | Controlled shutdown. | docker stop db_service |
docker kill <id> |
Force-stops container. | Kill unresponsive container. | docker kill web_app |
docker restart <id> |
Restarts container. | Apply config changes. | docker restart api_server |
docker rm <id> |
Removes stopped container. | Cleanup. | docker rm old_api |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker build -t <name> . |
Builds image from Dockerfile. | Create custom application image. | docker build -t my-api:v1 . |
docker rmi <image> |
Removes an image. | Free disk space. | docker rmi my-api:v1 |
docker image prune |
Removes unused images. | Routine cleanup. | docker image prune -a |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker-compose up -d |
Starts services. | Bring up full stack. | docker-compose up -d |
docker-compose down |
Stops + removes services. | Reset environment. | docker-compose down |
docker-compose ps |
Shows service status. | Check stack health. | docker-compose ps |
docker-compose logs <service> |
View logs. | Debug app. | docker-compose logs -f web |
docker-compose exec <service> <cmd> |
Run command in container. | DB shell, migrations. | docker-compose exec db psql |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker volume create <name> |
Creates volume. | Setup DB storage. | docker volume create pg_data |
docker run -v <vol>:<path> |
Mounts a volume. | Persist DB/files. | docker run -v pg:/var/lib/postgresql/data |
docker volume ls |
Lists volumes. | Storage audit. | docker volume ls |
docker volume rm <name> |
Removes volume. | Cleanup. | docker volume rm old_vol |
docker volume prune |
Removes unused volumes. | Maintenance. | docker volume prune |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker login |
Login to registry. | Push private images. | docker login |
docker push <image> |
Push image to registry. | Publish production images. | docker push myrepo/api:v1 |
docker pull <image> |
Pull image. | Deploy specific version. | docker pull myrepo/api:latest |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker network create <name> |
Creates network. | Isolated backend network. | docker network create backend |
docker network ls |
Lists networks. | Network audit. | docker network ls |
docker network connect <net> <container> |
Connects container to network. | Add new service to stack. | docker network connect backend api |
docker network disconnect <net> <container> |
Disconnects container. | Debug isolation. | docker network disconnect backend api |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker logs <id> |
View logs. | Debug failures. | docker logs -f web |
docker exec -it <id> /bin/bash |
Shell into container. | Inspect, debug. | docker exec -it api bash |
docker stats |
Real-time resource usage. | Monitor performance. | docker stats |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker system prune |
Remove unused containers, networks, images. | Full cleanup. | docker system prune -f |
docker container prune |
Remove stopped containers. | Dev/test cleanup. | docker container prune |
docker image prune -a |
Remove unused images. | Free disk space. | docker image prune -a |
docker volume prune |
Remove unused volumes. | Storage maintenance. | docker volume prune |
| Command | Description | Use Case | Example |
|---|---|---|---|
docker plugin enable <name> |
Enable plugin. | Activate drivers. | docker plugin enable my-driver |
docker plugin disable <name> |
Disable plugin. | Troubleshooting. | docker plugin disable my-driver |
docker plugin create <name> |
Create plugin. | Custom extensions. | docker plugin create custom-driver |
docker plugin inspect <name> |
View plugin info. | Validate config. | docker plugin inspect custom-driver |
docker plugin rm <name> |
Remove plugin. | Uninstall. | docker plugin rm custom-driver |
- Docker Docs: https://docs.docker.com
- Docker Compose Docs: https://docs.docker.com/compose
- “Docker Explained in 100 Seconds”
- “Docker Volumes Tutorial”
- “Docker Networking Explained”
| S.No. | Image |
|---|---|
| 1 | ![]() |
| 2 | ![]() |
| 3 | ![]() |
| 4 | ![]() |
| 5 | ![]() |
| 6 | ![]() |
| 7 | ![]() |
| 8 | ![]() |
| 9 | ![]() |
GitHub Repo: 👉 https://github.com/alok-kumar8765/docker_cheatcode
If you found this helpful, don’t forget to ⭐ star the repo!








