Day 20 of 90 Days of DevOps Challenge: Docker Mastery - Crafting The Ultimate Cheat-Sheet!
Finally!! 🎉
We've navigated through containers, images, volumes, and networks, and we've gained invaluable insights into Docker and Docker Compose. 🙌 Now, it’s time to take our Docker skills to the next level.
What’s Next? 🛠️
It’s time to consolidate our learning into a comprehensive cheat-sheet. This cheat-sheet will serve as both a personal reference and a valuable resource for the DevOps community. It will include essential Docker and Docker Compose commands, along with brief explanations of their usage. This resource is not only about showcasing our knowledge but also about contributing to the wider community by providing a practical guide for others.
Docker Commands Cheat-Sheet
Docker General Commands
Display Docker version:
docker --versionDisplay Docker info:
docker infoShow system-wide information:
docker system info
Docker Container Commands
List all containers (running and stopped):
docker ps -aList only running containers:
docker psStart a container:
docker start <container_id_or_name>Stop a container:
docker stop <container_id_or_name>Restart a container:
docker restart <container_id_or_name>Pause a container:
docker pause <container_id_or_name>Unpause a container:
docker unpause <container_id_or_name>Remove a container:
docker rm <container_id_or_name>Remove all stopped containers:
docker container pruneInspect a container:
docker inspect <container_id_or_name>View logs of a container:
docker logs <container_id_or_name>Execute a command in a running container:
docker exec -it <container_id_or_name> <command>
Docker Image Commands
List all images:
docker imagesPull an image from a registry:
docker pull <image_name>:<tag>Build an image from a Dockerfile:
docker build -t <image_name>:<tag> .Tag an image:
docker tag <image_id> <new_image_name>:<tag>Remove an image:
docker rmi <image_id_or_name>Remove all unused images:
docker image pruneInspect an image:
docker inspect <image_id_or_name>
Docker Volume Commands
List all volumes:
docker volume lsCreate a volume:
docker volume create <volume_name>Remove a volume:
docker volume rm <volume_name>Inspect a volume:
docker volume inspect <volume_name>Remove all unused volumes:
docker volume prune
Docker Network Commands
List all networks:
docker network lsCreate a network:
docker network create <network_name>Remove a network:
docker network rm <network_name>Inspect a network:
docker network inspect <network_name>Remove all unused networks:
docker network prune
Docker System Commands
Show system-wide information:
docker system infoRemove unused data (containers, networks, images, volumes):
docker system pruneRemove unused data with more aggressive pruning:
docker system prune -a
Docker Compose Commands
Check Docker Compose version:
docker-compose --versionStart services defined in docker-compose.yml:
docker-compose upStart services in detached mode:
docker-compose up -dStop and remove containers, networks, volumes, and images:
docker-compose downRebuild services:
docker-compose buildView logs of services:
docker-compose logsExecute a command in a running service:
docker-compose exec <service_name> <command>Run a one-off command:
docker-compose run <service_name> <command>Remove stopped service containers:
docker-compose down --volumes
Docker Registry Commands
Login to Docker Hub:
docker loginLogout from Docker Hub:
docker logoutPush an image to a registry:
docker push <image_name>:<tag>
Why This Cheat-Sheet? 🤔
Creating a cheat-sheet not only reinforces your own learning but also provides a valuable resource for others in the DevOps community. This cheat-sheet will help streamline your workflow, making Docker and Docker Compose easier to use and understand.
Spread the Knowledge! 😃
Once you’ve created your cheat-sheet too, share it on LinkedIn and let others benefit from your hard work. This is a great way to contribute to the community and showcase your expertise.
Happy Dockering! 🚀
Our journey in Docker doesn't end here. Let us keep experimenting, learning, and sharing your knowledge. The DevOps community will surely appreciate our contribution.