"The Ultimate Docker Cheat Sheet for DevOps: Essential Commands & Tips to Master Containers! ๐Ÿณ๐Ÿ“‹๐Ÿš€"

Saksham KambleSaksham Kamble
5 min read

Day 20: Docker for DevOps Engineers - Creating Your Ultimate Docker Cheat Sheet ๐Ÿš€๐Ÿ“„

Congratulations! ๐ŸŽ‰ You've completed the hands-on sessions with Docker, mastering everything from building images and managing containers to configuring networks and volumes. Now, it's time to put it all together into one valuable resourceโ€”a Docker Cheat Sheet! This will be your go-to guide, packed with essential commands and explanations to make Docker easier for you and help others in the DevOps community. ๐Ÿ™Œ

Letโ€™s dive into how you can create a cheat sheet thatโ€™s unique, informative, and accessible to anyone, even if theyโ€™re new to Docker. ๐Ÿ’ก


Why Create a Docker Cheat Sheet? ๐Ÿค”

Having a Docker cheat sheet is like having a quick reference guide for everything youโ€™ve learned:

  • Efficiency: Find the exact command you need without searching online or reading through long documents.

  • Learning Tool: Reinforces your knowledge and helps you retain what youโ€™ve learned.

  • Community Support: Sharing this cheat sheet on LinkedIn helps others who are learning Docker, adding value to the DevOps community. ๐Ÿ‘

  • ๐Ÿณ Docker Cheat Sheet

    1. Docker Basics ๐Ÿ”น

    | Command | Description | | --- | --- | | docker --version | Show Docker version installed | | docker info | Display Docker system information | | docker help | List available Docker commands | | docker run <image> | Run a new container | | docker run -d <image> | Run container in detached mode | | docker run -it <image> bash | Start a container interactively | | docker ps | List running containers | | docker ps -a | List all containers (including stopped) | | docker stop <container> | Stop a running container | | docker start <container> | Start a stopped container | | docker restart <container> | Restart a container | | docker rm <container> | Remove a stopped container | | docker rmi <image> | Remove an image | | docker system prune | Remove unused data (containers, images, networks) | | docker top <container> | Show processes running inside a container | | docker stats | Display a live stream of container stats |

    2. Working with Docker Images ๐Ÿ–ผ๏ธ

    | Command | Description | | --- | --- | | docker pull <image> | Download an image from Docker Hub | | docker images | List all downloaded images | | docker build -t <image_name> . | Build an image from a Dockerfile | | docker tag <source_image> <new_image:tag> | Add a tag to an image | | docker push <image> | Push an image to Docker Hub | | docker history <image> | View history of an image | | docker inspect <image> | Show details of an image | | docker image prune | Remove unused images |

    3. Container Management โš™๏ธ

    | Command | Description | | --- | --- | | docker exec -it <container> <command> | Execute a command inside a running container | | docker logs <container> | View logs from a container | | docker cp <container>:/path/to/file . | Copy file from container to local system | | docker commit <container> <new_image> | Create a new image from container changes | | docker rename <old_name> <new_name> | Rename a container | | docker diff <container> | Show changes to files/folders in containerโ€™s filesystem |

    4. Docker Volumes ๐Ÿ“‚

    | Command | Description | | --- | --- | | docker volume create <volume_name> | Create a new volume | | docker volume ls | List all volumes | | docker volume rm <volume_name> | Remove a volume | | docker run -v <volume_name>:/path <image> | Mount volume to a container | | docker volume inspect <volume_name> | View details of a volume | | docker volume prune | Remove all unused volumes |

    5. Docker Networks ๐ŸŒ

    | Command | Description | | --- | --- | | docker network create <network_name> | Create a new network | | docker network ls | List all networks | | docker network rm <network_name> | Remove a network | | docker network inspect <network_name> | View details of a network | | docker run --network <network_name> <image> | Connect a container to a specific network | | docker network connect <network_name> <container> | Connect an existing container to a network | | docker network disconnect <network_name> <container> | Disconnect a container from a network |

    6. Docker Compose ๐Ÿ“œ

    | Command | Description | | --- | --- | | docker-compose up | Start all services defined in docker-compose.yml | | docker-compose up -d | Start services in detached mode | | docker-compose down | Stop and remove containers, networks, volumes | | docker-compose ps | List containers managed by Docker Compose | | docker-compose logs | View logs for all services | | docker-compose logs <service> | View logs for a specific service | | docker-compose build | Build images defined in docker-compose.yml | | docker-compose stop | Stop all services | | docker-compose start | Start all stopped services | | docker-compose restart | Restart all services | | docker-compose exec <service> <command> | Run a command in a service container | | docker-compose config | Validate and view docker-compose.yml configuration |

    7. Useful Docker Utilities ๐Ÿ› ๏ธ

    | Command | Description | | --- | --- | | docker save -o <file>.tar <image> | Save an image to a tar archive | | docker load -i <file>.tar | Load an image from a tar archive | | docker export -o <file>.tar <container> | Export containerโ€™s filesystem to a tar file | | docker import <file>.tar | Import tar file as an image | | docker events | Real-time events from the Docker server | | docker container stats | Monitor resource usage stats for containers |

    How to Use This Cheat Sheet ๐Ÿ“–

    1. Bookmark It: Save this cheat sheet for quick reference whenever youโ€™re working with Docker.

    2. Share with Others: Share this cheat sheet with anyone whoโ€™s learning Docker or working in DevOps.

    3. Customize for Your Needs: Feel free to add more commands or remove those you donโ€™t use often. Make it your personal go-to guide!

0
Subscribe to my newsletter

Read articles from Saksham Kamble directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Saksham Kamble
Saksham Kamble