List of 20 docker commands and its use cases with example?

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

1. docker -version

This command is used to get the currently installed version of docker

docker -version

2. docker pull

This command is used to pull images from theĀ docker repository(hub.docker.com)

docker pull ubuntu

3. docker create

This command is used to create container from an image

docker create ubuntu

4. docker start

This command is used to start the container

docker start fe6e370a1c9c

5. docker run

This command is used to create and run a container from an image

docker run -it -d ubuntu

6. docker ps

This command is used to list the running containers

docker ps

7. docker ps -a

This command is used to show all the running and exited containers

docker ps -a

8. docker exec

This command is used to access the running container

docker exec -it fe6e370a1c9c /bin/bash

9. docker stop

This command stops a running container

docker stop fe6e370a1c9c

10. docker kill

This command kills the container by stopping its execution immediately. The difference between ā€˜docker killā€™ and ā€˜docker stopā€™ is that ā€˜docker stopā€™ gives the container time to shutdown gracefully, in situations when it is taking too much time for getting the container to stop, one can opt to kill it.

docker kill fe6e370a1c9c

11. docker commit

This command creates a new image of an edited container on the local system

docker commit fe6e370a1c9c bhanuprakash8008/newubuntu

12. docker login

This command is used to login to the docker hub repository

docker login

13. docker push

This command is used to push an image to the docker hub repository

docker push bhanuprakash8008/newubuntu

14. docker images

This command lists all the locally stored docker images

docker images

15. docker rm

This command is used to delete a stopped container

docker rm fe6e370a1c9c

16. docker rmi

This command is used to delete an image from local storage

docker rmi 0678ee2e6b1e

17. docker build

This command is used to build an image from a specified docker file

docker build .

18. docker logs

This command is used to display the logs of specific container

docker logs -f fe6e370a1c9c

19. docker system

This command is used to remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.

docker system prune
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x