Day 20: Docker Cheat sheet
Docker Cheat sheet for DevOps Engineers
Welcome back to our #90DaysOfDevOps series! Today, we're diving into the essential Docker commands you need to master as a DevOps Engineer. Docker is a powerful tool that simplifies the process of deploying applications in containers. Here's a detailed cheat sheet to help you get started and enhance your Docker skills.
Introduction to Docker
Docker is a platform designed to make it easier to create, deploy, and run applications using containers. Containers allow developers to package an application with all its dependencies, ensuring consistency across multiple environments.
Docker Cheat Sheet ๐
Here's a detailed Docker cheat sheet in a tabular format for your reference:
Command | Description |
docker --version | Show Docker version. |
docker run [OPTIONS] IMAGE [COMMAND] | Run a command in a new container. |
docker ps | List running containers. |
docker ps -a | List all containers, including stopped ones. |
docker images | List all Docker images. |
docker pull IMAGE | Pull an image from a registry. |
docker build -t NAME:TAG . | Build an image from a Dockerfile. |
docker push NAME:TAG | Push an image to a registry. |
docker exec -it CONTAINER COMMAND | Execute a command in a running container. |
docker stop CONTAINER | Stop a running container. |
docker start CONTAINER | Start a stopped container. |
docker restart CONTAINER | Restart a running container. |
docker rm CONTAINER | Remove a stopped container. |
docker rmi IMAGE | Remove an image. |
docker logs CONTAINER | View logs of a container. |
docker inspect CONTAINER | Display detailed information about a container or image. |
docker commit CONTAINER NEW_IMAGE | Create a new image from a container's changes. |
docker tag IMAGE NEW_TAG | Tag an image with a new name. |
docker network ls | List all Docker networks. |
docker network create NETWORK | Create a new network. |
docker network connect NETWORK CONTAINER | Connect a container to a network. |
docker volume ls | List all Docker volumes. |
docker volume create VOLUME | Create a new volume. |
docker volume rm VOLUME | Remove a volume. |
docker-compose up -d | Start all services defined in a docker-compose.yml file in detached mode. |
docker-compose down | Stop and remove containers, networks, images, and volumes defined in a docker-compose.yml file. |
docker-compose logs | View logs of services defined in a docker-compose.yml file. |
docker-compose ps | List containers in a docker-compose.yml file. |
Docker is an indispensable tool for modern DevOps practices, enabling the creation, deployment, and management of applications in a streamlined and consistent manner. Mastering these Docker commands will significantly enhance your ability to manage containerized applications efficiently.
Keep practicing and experimenting with these commands to become proficient in Docker. Happy coding! ๐
Subscribe to my newsletter
Read articles from Gunjan Bhadade directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by