Day 20: Docker Cheat sheet

Gunjan BhadadeGunjan Bhadade
3 min read

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:

CommandDescription
docker --versionShow Docker version.
docker run [OPTIONS] IMAGE [COMMAND]Run a command in a new container.
docker psList running containers.
docker ps -aList all containers, including stopped ones.
docker imagesList all Docker images.
docker pull IMAGEPull an image from a registry.
docker build -t NAME:TAG .Build an image from a Dockerfile.
docker push NAME:TAGPush an image to a registry.
docker exec -it CONTAINER COMMANDExecute a command in a running container.
docker stop CONTAINERStop a running container.
docker start CONTAINERStart a stopped container.
docker restart CONTAINERRestart a running container.
docker rm CONTAINERRemove a stopped container.
docker rmi IMAGERemove an image.
docker logs CONTAINERView logs of a container.
docker inspect CONTAINERDisplay detailed information about a container or image.
docker commit CONTAINER NEW_IMAGECreate a new image from a container's changes.
docker tag IMAGE NEW_TAGTag an image with a new name.
docker network lsList all Docker networks.
docker network create NETWORKCreate a new network.
docker network connect NETWORK CONTAINERConnect a container to a network.
docker volume lsList all Docker volumes.
docker volume create VOLUMECreate a new volume.
docker volume rm VOLUMERemove a volume.
docker-compose up -dStart all services defined in a docker-compose.yml file in detached mode.
docker-compose downStop and remove containers, networks, images, and volumes defined in a docker-compose.yml file.
docker-compose logsView logs of services defined in a docker-compose.yml file.
docker-compose psList 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! ๐Ÿš€

0
Subscribe to my newsletter

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

Written by

Gunjan Bhadade
Gunjan Bhadade