📂Day 20 - Docker Cheat Sheet
Docker is like a super tool that helps developers put their apps in containers. It's great for everyone, whether you're just starting out or want to get better at Docker. This cheat sheet will help you with installing Docker, managing volumes (like extra storage for your containers), handling images (like app blueprints), and doing things with containers (like starting, stopping, and removing them).
💿Image Management:
Command | Description |
docker images | List all images. |
docker pull [image_name] | Download an image. |
docker rmi [image_id] | Remove an image. |
docker build -t [image_name] [dockerfile_path] | Build an image from a Dockerfile. |
💿Docker Container:
docker ps | List running containers. |
docker ps -a | List all containers. |
docker run [options] [image_name] | Create and start a container. |
docker start [container_id] | Start a stopped container. |
docker stop [container_id] | Stop a running container. |
docker rm [container_id] | Remove a container. |
docker exec [options] [container_id] [command] | Run a command in a running container. |
docker cp [source_path] [container_id]:[destination_path] | Copy files between a container and the local filesystem. |
docker logs [container_id] | Fetch the logs of a container. |
💿Docker Volume:
docker volume ls | List volumes. |
docker volume create [options] [volume_name] | Create a volume. |
docker volume inspect [volume_name] | Inspect a volume. |
docker volume rm [volume_name] | Remove a volume. |
💿Docker Networking:
docker network ls | List networks. |
docker network inspect [network_id] | Inspect a network. |
docker network create [options] [network_name] | Create a network. |
docker network connect [network_id] [container_id] | Connect a container to a network. |
docker network disconnect [network_id] [container_id] | Disconnect a container from a network. |
💿Docker Compose:
docker-compose [options] [command] [services] | Manage multi-container Docker applications. |
Options: | |
--file [docker-compose.yml] : Specify an alternate compose file. | |
--project-name [project_name] : Specify an alternate project name. | |
Commands: | |
up : Create and start containers. | |
down : Stop and remove containers, networks, and volumes. | |
build : Build or rebuild services. | |
start : Start services. | |
stop : Stop services. |
With this cheat sheet in hand, you're all set to navigate Docker like a pro! Share this valuable resource with the DevOps community to spread the knowledge. Keep learning and exploring, as Docker has a lot to offer. Here's to happy containerizing and seamless deployment!🚀🐳
Hope you find it helpful !😊
Subscribe to my newsletter
Read articles from Sandeep Kale directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by