Docker Commands with example
Tags: docker, programming
Published: 2024-02-13 11:36:21

---
title: Docker Commands with example
published: true
date: 2023-08-02 06:29:42 UTC
tags: Docker,Programming
canonical_url: 
---

Looking for Docker commands to streamline and simplify your workflow? Check out the following examples for a quick and easy start. Remember to follow each command to ensure smooth and efficient execution carefully. With these commands, you’ll be well on mastering Docker and its powerful features.

### docker **ps** Process Status command in Docker

### Docker **ps** Process Status command in Docker:

**The docker** ps command is used to see the list of running containers.

Docker PS command example with output:

![Docker ps](https://pratikpathak.com/wp-content/uploads/2023/08/image-1024x159.png)

It will only show you the running containers. To see all containers, including stopped ones, use the “docker ps -a” command

### docker **rm** remove Container command in Docker

### Docker **rm** remove Container command in Docker:

The docker rm command is used to remove the container which is in the “Exited” state. You can use `docker stop containerID` the command to stop the container and then remove it. In place of “containerID,” you can specify the container’s name.

Example of docker rm command:

![docker rm command](https://pratikpathak.com/wp-content/uploads/2023/08/image-1-1024x186.png)

In the “containerID” you need to specify only some starting character enough to distinguish from other

If it prints the same containerID/name back that you specified, it means the command has been executed successfully.

### docker **images** Image command in Docker

### Docker **images** Image command in Docker:

The Docker images command is used to list down all the locally available images in Docker. These images are used to create containers.

Example of docker images command:

![Docker Images command example](https://pratikpathak.com/wp-content/uploads/2023/08/image-3-1024x342.png)

### docker **rmi** remove Image command in Docker

### Docker **rmi** remove Image command in Docker:

The docker rmi command is used to remove the image file. Any other container should not use the image file.

You need first to remove the container which uses the image file. Then only you can remove the image

Example of docker rmi command:

![Docker rmi command](https://pratikpathak.com/wp-content/uploads/2023/08/image-2-1024x319.png)

If it prints the same containerID/name back that you specified, it means the command has been executed successfully.

### docker **run** command Run Container Images in Docker

### Docker **run** command Run Container Images in Docker

The docker run command is used to create containers by using an image, and this command has a lot of flags and variations. You can find them in detail here…

> [Docker Run Command example the ultimate cheatsheet](https://pratikpathak.com/docker-run-command-cheatsheet/)

<iframe sandbox="allow-scripts" security="restricted" title="“Docker Run Command example the ultimate cheatsheet” — Pratik Pathak" src="https://pratikpathak.com/docker-run-command-cheatsheet/embed/#?secret=7fAImU4PMN#?secret=gWoTJBeR2Y" data-secret="gWoTJBeR2Y" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>

_Docker Run Command with example_

### docker **exec** Execute command in Docker

### Docker **exec** Execute command in Docker:

The Docker exec command runs some commands inside the Docker terminal. The Syntax of the docker exec command is…

```
docker exec containerID command
```

Docker exec command with an example:

![Docker exec command](https://pratikpathak.com/wp-content/uploads/2023/08/image-4-1024x239.png)

### docker **volume** Create Volume in Docker

### Docker **volume** Create Volume in Docker:

When you use the docker volume command, you can easily create a volume and link it with the container. This helps simplify the process and makes managing your container much more efficient.

Generrally, we don’t use the “docker volume” command since the “docker run -v” command creates the volume if it doesn’t exist.

### docker **inspect** Inspect command in Docker

### docker **logs** Logs command in Docker