15 Docker Commands you should know
Tags: docker, devops, cloud, azure
Published: 2022-03-08 06:19:44

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718330094/ytrR5AUUC.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718385983/UPXJnkLnv.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718418269/p9PELX28z.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718453863/YwSF62RqP.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718506497/tNMxO_LnC.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718555532/Ua1PF19oO.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718883587/omM3cluyJ.png)
docker stop stops a container with container id mentioned in the command. 

![Screenshot 2022-03-08 at 11.25.00 AM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718912987/aqro1yVNM.png)
To restart the docker container, we use docker restart.

![Screenshot 2022-03-08 at 11.25.27 AM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718937274/uZ78J_ZHh.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646718995370/QhDRTajFy.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719046660/tK3n-SJ_c.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719267842/VUzElNDLC.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719306601/eX7RrowWF.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719455889/4b_68PEWv.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719494374/_eXD1cgCl.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719530324/4tI3n2I-k.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719729466/14yeRnox-.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719917955/vuZSC4Q2-.png)

**15. docker logout**

Logging out from dockerhub.

![Screenshot 2022-03-08 at 11.42.17 AM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1646719949918/vQ81R31Z7.png)


### Connect with me on 
<a href="https://www.linkedin.com/in/srinivas-karnati">
  <img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" /> 
 </a> 
<a href="https://twitter.com/__karnati">
  <img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white"   />
</a>