# Docker Commands with Examples


### **docker --version**

This command is used to get the currently installed version of docker
![docker-version.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655733542232/Xkhe1fy1p.PNG align="left")
**docker pull**

**Usage: docker pull [image name]**

This command is used to pull images .
Docker looks for this image on our local system. When it can’t find the image, Docker downloads it from Docker Hub for us.
![docker-pull.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655733587345/wY0WrIMAB.PNG align="left")

### **docker run**

**Usage: docker run -it -d [image name]**

This command is used to create a container from an image

![docker-run.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655798139755/v0KK2ZcYt.PNG align="left")

### **docker ps**

This command is used to list the running containers

![docker-c-list.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655799275645/FY8VtmI_0.PNG align="left")

### **docker ps -a**

This command will show all the containers both stopped and running.

![docker-ps-a.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655799348876/eB0AhjLoZ.PNG align="left")

### **docker images**

This command lists all the docker images.

![image-list.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655799650990/2f3flmEu8.PNG align="left")

### **docker rm**

**Usage: docker rm [container id]**

This command is used to delete a stopped container.
(First stop the container before delete it. Because running container cant be delete )

![rm-c.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655800115315/AnJxSDFut.PNG align="left")

### **docker rmi**

**Usage: docker rmi [image id]**

This command is used to delete a image.
![remove-image.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655800884077/vmEZhXAYe.PNG align="left")

### **docker stop**

**Usage: docker stop [container id]** or ** docker container stop [container id]**

This command stops a running container.

![stop-c.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655800497558/eAYSQ60kO.PNG align="left")

![container-stop.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655800526128/Vgr8ETN4F.PNG align="left")

### **docker build**

**Usage: docker build [path to docker file]**

The docker build command builds Docker images from a Dockerfile

![build.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655802776930/uJqGOOq-b.PNG align="left")















