DEV Community

Pratik Pathak
Pratik Pathak

Posted on • Originally published at pratikpathak.com on

Docker Commands with example

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

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

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

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

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

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
Enter fullscreen mode Exit fullscreen mode

Docker exec command with an example:

Docker exec command

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

Top comments (0)