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!
1.docker –version: This command helps you know the installed version of the docker software on your system.
2.docker pull nginx: This command helps you pull images from the central docker repository.
3.docker images: This command helps you in listing all the docker images, downloaded on your system.
4.docker run –it -d centos: This command helps in running containers, from their image name.
-It = which basically makes the terminal interactive.
-d = which means run the container as a daemon and that should be run the container in the background.
5.docker ps: This command helps in listing all the containers which are running in the system.
6.docker ps –a: if there are any stopped containers, they can be seen by adding the “-a” flag in this command.
7.docker stop container ID (or) name: This command will stop the containers which are running.
8.docker exec –it container id bash (current terminal space): for logging into/accessing the container, one can use the exec command.
9.docker kill container id: This container kills the container by stopping its execution immediately. The difference between ‘docker kill’ and ‘docker stop’ gives the container time to shutdown in any situations, when it is taking too much time for getting the container to stop, one can opt to kill it.
10.docker rm container Id: To remove a stopped container from the system, we use the rm command.
11.docker rmi image id: To remove an image from the system we use the command “rmi”.