Docker Commands

Docker provides commands which interact and work in client-server environment. Docker is Linux compliant software.
We have listed some important and useful Docker commands as below:.

Docker version:- This command is used to show the version of installed Docker on your machine.

sudo docker version

Docker commands

Docker Run:- The docker run command creates a container from a given image and starts the container using a given command.

docker run -d ubuntu    

-d : It is used to run containers in detached mode.

creates a container

Docker images:– This command is used to display all the images currently installed on your system.

docker images

Docker images

Docker ps:- ps stands for ‘process status’ which shows the status of all running processes along with their IDs. docker ps is a majorly used command which is used to view all the running containers along with their container ID.

docker ps -l  

-l : it is used to show the latest available container.


Docker ps – a

docker ps -a  

The -a option is used to list all containers. As below:

list all containers

Docker stop: This below command is used to stop the running container:

docker stop container_id 

container_id : It is an Id assigned by the Docker to the container.


Docker rmi:- This command is used to remove the docker image

docker rmi image-id 

remove the docker image

Delete all images:- This command is used to remove all docker images

docker rmi $(docker images -q)

remove all docker images

Delete all images forcefully:- This command is used to remove all docker images forcefully.

docker rmi -f $(docker images -q) 

-f : It is used to delete images forcefully. This will delete all the images even if it is used by a running container.

 delete images

Docker rm:- This command is used to delete all the running containers.

docker rm -f $(docker ps -a -q)

delete all the running containers

Docker exec:- This command is used to enter into Docker container

docker exec -it container-id /bin/bash

docker exec

Inspect information of a container

sudo docker inspect (container-id)

docker inspect

Build Docker Image from a Dockerfile

docker build -t image-name docker-file-location 

-t : it is used to tag Docker images with the provided name.

Docker images

Mount Volume to a docker container, using below command we can mount (

Docker with volume

docker run -it -d -v <path/of/volume>:<path/of/volume/inside/container> (image-name)

-v: It is used to mount volume

mount volume

Subscribe Now