Q2. What is the difference between docker stop and docker kill?

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

One can stop and kill a running container. Docker stop will only stop the container gracefully. Docker kill will immediately kills all the process. There is a difference in exit code..

root@ip-172-31-28-155:/home/ubuntu# docker stop rajuc
rajuc
root@ip-172-31-28-155:/home/ubuntu# docker ps -a | grep rajuc
548886386f8b   httpd          "httpd-foreground"       30 minutes ago      Exited (0) 7 seconds ago                rajuc


root@ip-172-31-28-155:/home/ubuntu# docker kill rajuc
rajuc
root@ip-172-31-28-155:/home/ubuntu# docker ps -a | grep rajuc
548886386f8b   httpd          "httpd-foreground"       31 minutes ago      Exited (137) 8 seconds ago              rajuc