Docker Commands Cheat Sheet : The Top 30 commands

Welcome all the Techies on the beautiful article which has the panacea needed to start your journey as a DevOps.

Docker is a powerful containerization platform that allows developers to package and distribute applications along with their dependencies, ensuring consistency and portability across different environments. To make the most of Docker, it’s essential to have a solid understanding of its commands and their functionalities. In this article, we’ll provide a comprehensive Docker commands cheat sheet to help you navigate through the containerization process efficiently..

Docker Commands Cheat Sheet

You may also like:

[2023] netstat Command To Check Port: A powerful tool in a network admin’s arsenal.

2023 What Is Top Command In Linux: An In-Depth Guide for the BEST system admins

Is DNS Adguard Safe in 2023? Exploring the Security and Reliability of Adguard DNS

Grab Docker Deep Dive: Zero to Docker in a Single Book – 2023 Edition

First, let us see some basics to start with before checking the Docker Commands Cheat Sheet.

What is Docker in DevOps?

Docker is an open-source platform that enables developers to build, ship, and run applications inside containers. Containers are lightweight, portable, and isolated environments containing all the components necessary for an application to run successfully. With Docker, developers can eliminate the “it works on my machine” problem and ensure consistent behaviour across different environments.

Docker Basics

Please note that Image doesn’t mean a docker image because docker is not the only containerisation tool in the market.

What is a Docker Image or just an image?

In Docker, an image is a read-only template used to create containers. It contains the application code, libraries, dependencies, and other files needed to run the application. Docker images are the building blocks of containers.

What is a Docker Container or just a container?

A container is a runnable instance of a Docker image. It encapsulates the application and its environment, providing isolation from the host system and other containers. Containers are lightweight and share the host OS kernel, making them efficient and fast.


A Dockerfile is a text file that contains instructions to build a Docker image. It specifies the base image, adds application code, sets environment variables and configures the container. Dockerfiles help automate the image creation process.

Docker Registry

Docker images are stored in repositories in a Docker registry. Docker Hub is the default public registry that hosts a vast number of pre-built images. Developers can also set up their private Docker registries for secure image storage.

How many commands are in docker?

There is no specific number of commands in docker. It depends on several factors like the Docker version, updates etc.

We can say that Docker has over 50 core commands covering various aspects of managing containers, images, networks, volumes, and other functionalities.

Docker Commands Cheat Sheet: Docker commands list

Below is the list of


docker image ls: List all Docker images on your system.
docker image pull <image_name>:<tag>: Download an image from Docker Hub.
docker image build -t <image_name>:<tag> <path_to_dockerfile>: Build a Docker image from a Dockerfile.
docker image rm <image_id>: Remove a Docker image from your system.


docker ls: List all running Docker containers.
docker ps -a: List all Docker containers (including stopped ones).
docker run <image_name>:<tag>: Create and start a new container from an image.

docker start <container_id>: Start a stopped container.
docker stop <container_id>: Stop a running container.

docker restart <container_id>: The docker restart command is used to restart a running or stopped container.
docker rm <container_id>: Remove a stopped container from your system.

docker run -p host port:containerport <image>: This will map the host port with the container port to access the image data.

docker build -t my-app. : The docker build command is used to build a Docker image from a Dockerfile

docker pull ubuntu:latest: The docker pull command is used to pull an image or a repository from a Docker registry.

docker push my-app:latest: The docker push command is used to push a Docker image or a repository to a Docker registry.

docker exec -it container_id /bin/bash: The docker exec command is used to execute a command in a running container.

docker logs container_id: The docker logs command is used to view the logs of a container for troubleshooting purposes.

Docker Compose:

docker-compose up: Create and start containers defined in a docker-compose.yml file.
docker-compose down: Stop and remove containers defined in a docker-compose.yml file.
docker-compose build: Build or rebuild services defined in a docker-compose.yml file.


docker volume lsList all Docker volumes on your system.
docker volume create <volume_name>: Create a Docker volume.
docker volume inspect <volume_name>: Display detailed information about a volume.
docker run -v <host_path>:<container_path>: Mount a host directory as a volume in a container.


docker network ls: List all Docker networks on your system.
docker network create <network_name>: Create a Docker network.
docker network connect <network_name> <container_name>: Attach a container to a network.
docker network disconnect <network_name> <container_name>: Detach a container from a network.

Cleaning Up:

docker system df: Show disk usage related to Docker resources.
docker system prune: Remove unused data, including stopped containers and dangling images.

How to list all docker commands?

To list all Docker commands, you can use the docker command-line tool with the –help option.

docker –help

Additionally, you can get more detailed information about a specific Docker command by appending –help to the command.

docker run –help // You can replace run with any other command.

Remember, this is just a basic Docker Commands Cheat Sheet to get you started. Docker has many more options and features, so feel free to explore the official Docker documentation for more advanced usage.

If you want anything related to DevOps, please comment and we will get you more details.

Happy Dockerizing!

FAQs (Frequently Asked Questions)

Q. What is the difference between an image and a container in Docker?

A. In Docker, an image is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software. On the other hand, a container is an instance of a Docker image that runs on the host system and is isolated from other containers.

Q. How do I remove a Docker image?

A. To remove a Docker image, you can use the docker rmi command followed by the image ID or name.

Q. Can I run multiple containers from the same image?

A. Yes, you can run multiple containers from the same Docker image. Each container will be an independent instance of the image.

Q. How do I pass environment variables to a Docker container?

A. You can pass environment variables to a Docker container using the -e flag with the docker run command.

Q. What is Docker Compose, and why is it used?

A. Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to easily specify the services, networks, and volumes required for your application in a single YAML file and manage the entire application stack.

Q. How to learn docker commands?

A. Simply use the docker –help to see all the commands; the most important thing is to Practice learning to learn learning docker commands.

Q. Can I use multiple CMD in docker?

A. Yes, you can run multiple CMD in docker using the operators like && which executes the first command and then runs the second command.

Q. What is the basic command for docker run?

A. You can simply run docker by using the command run docker run <image_name>:<tag>

Q. How do I list all running docker images?

A. You can list all the running docker images using the command docker images

Q. What is a Docker daemon?

A. Docker daemon is a process that manages Docker images, containers, networks, and volumes.

Q. How to reduce Docker file size?

A. A Docker image is made of multiple ordered build instructions which are known as layers. Docker image size depends on the number of layers. We can reduce the number of layers to reduce the docker file size.

Q. What is ENTRYPOINT in Dockerfile?

A. If we type docker inspect <imagename> or <containername> and there you can see an entry “ENTRYPOINT” which is an instruction to configure like a script to run as soon as the container starts.
Q. What is a container in docker?
A. A container in a docker is a runnable instance of a Docker image. It provides isolation between the host system and other containers. Containers are lightweight and share the host OS kernel, making them efficient and fast.
Q. Is Docker used by DevOps?
A. Straight answer is yes. We use Docker or a similar containerisation tool in DevOps.

3 thoughts on “Docker Commands Cheat Sheet : The Top 30 commands”

Leave a comment