DEV Community

Cover image for 15 Docker Commands you should know
Srinivas karnati
Srinivas karnati

Posted on

15 Docker Commands you should know

Docker is a containerization system which packages and runs the application with its dependencies inside a container. In this article, I mentioned about 18 Docker Commands you need to know while working with Docker.

1. docker --version

One of the first things we all want to know is how to find the installed docker version.

Screenshot 2022-03-08 at 11.15.10 AM.png

2. docker pull

The 'docker pull' is a Docker command to download a Docker image or a repository locally on the host from a public or private registry.

Screenshot 2022-03-08 at 11.16.15 AM.png

3. docker images

List all the docker images pulled on the system with image details such as TAG/IMAGE ID/SIZE etc.

Screenshot 2022-03-08 at 11.16.48 AM.png

4. docker run

The docker run command creates a container from a given image and starts the container using a given command. It is one of the first commands you should become familiar with when starting to work with Docker.

Screenshot 2022-03-08 at 11.17.23 AM.png
If the image is not present locally, docker first pulls the image from the repository and runs it.

Screenshot 2022-03-08 at 11.18.15 AM.png
5. docker ps

docker ps command lists all the docker containers are running with container details. To list all the docker containers running/exited/stopped with container details, we use docker ps -a command

Screenshot 2022-03-08 at 11.18.52 AM.png

6. docker start/ stop/restart

docker start command in docker starts the docker container with container id mentioned in the command.

Screenshot 2022-03-08 at 11.24.31 AM.png
docker stop stops a container with container id mentioned in the command.

Screenshot 2022-03-08 at 11.25.00 AM.png
To restart the docker container, we use docker restart.

Screenshot 2022-03-08 at 11.25.27 AM.png
7. docker rm

Remove the docker container with container id mentioned in the command.

Screenshot 2022-03-08 at 11.26.21 AM.png
8. docker rmi

Remove the docker image with the docker image id mentioned in the command

Screenshot 2022-03-08 at 11.27.13 AM.png

9. docker commit

Create a new image from a container’s changes. It can be useful to commit a container’s file changes or settings into a new image.

Screenshot 2022-03-08 at 11.30.56 AM.png
10. docker login

Login into docker hub. You will be asked your docker hub credentials to log in.

Screenshot 2022-03-08 at 11.31.33 AM.png
I already had my credentials setup, so it didn't ask me to enter login id and password.
11. docker push

Upload a docker image with the image name mentioned in the command on the dockerhub.

Screenshot 2022-03-08 at 11.31.33 AM.png
Once it is successful, you would be able to see the docker image in your docker hub repo.

Screenshot 2022-03-08 at 11.34.06 AM.png
12. docker info

Get detailed information about docker installed on the system including the kernel version, number of containers and images, etc.

Screenshot 2022-03-08 at 11.35.18 AM.png
13. docker history

Shows the history of a docker image with the image name mentioned in the command.

Screenshot 2022-03-08 at 11.37.10 AM.png

14. docker search

Search for a docker image on dockerhub with the name mentioned in the command.

Screenshot 2022-03-08 at 11.41.43 AM.png

15. docker logout

Logging out from dockerhub.

Screenshot 2022-03-08 at 11.42.17 AM.png

Connect with me on






Top comments (0)