Docker commands with examples

What you will learn here about Docker

  • Docker commands with examples

Docker commands with examples

Here we will see most common docker commands with example

1)Docker command to check the docker version

docker version

2)Docker command to check the detailed information on the running/stopped containers

docker info

3)How to download tomcat image from docker hub

docker pull <image name>
Example : docker pull tomcat

4)How to verify downloaded docker images

docker images

5)How to view all the commands that were run on the image

docker history <image name>
Example : docker history tomcat

6)How to remove docker image

docker rmi <image name>
Example : docker rmi tomcat

7)How to search image with 20 search result

docker search <image name> | head -<result limit>
Example : docker search ubuntu | head -20

8)Docker command to list all containers

docker ps

9)Docker command to identify the IP address of the running container

docker inspect <container name>
Example : docker inspect nginxservice

10)Docker command to print the stats for a running container

docker stats <container name>
Example : docker stats nginxservice

11)Docker command to pause the processes in a running container

docker pause <container name>
Example : docker pause nginxservice

12)Docker command to unpause the process in a running container

docker unpause <container name>
Example : docker unpause nginxservice

13)Docker command to kill the processes in a running container

docker kill <container name>
Example : docker kill nginxservice

14)Docker command to start the container

docker start <container name>
docker start nginxservice

15)Docker command to stop the container

docker stop <container name>
docker stop nginxservice

16)Docker command to see container we just stopped

docker ps -a

17)Docker command to delete a container

docker rm <container name>
docker rm nginxservice

18)Docker command to remove all stopped containers

docker container prune

19)Docker command to export container

docker export <container name> > <file name>.target
Example : docker export nginxservice > test.tar

20)Docker command to import a container

docker import <tar file name>
docker import abc.tar

You may also like...