I want to know, which command of docker-compose I have to use in which case, down, kill and stop? What is the difference between them?
I want to know, which command of docker-compose I have to use in which case, down, kill and stop? What is the difference between them?
As documentation of docker-compose says:
So, if you can wait for a while, and you want to do a simple, "hot" restart, without removing or disabling Docker infrastructure elements (like containers or networks), you should use docker-compose stop. This is the least invasive option.
If you hurry up, and you don't want to wait for a graceful stop operation, but you also don't want to remove containers, you should use docker-compose kill. The container stops working, but it is ready to be started again.
And if you are not interested in preserving containers at all, you can use docker-compose down. This scenario is a kind of "cold" restart.
Note that you can also use docker-compose pause, which pauses running containers of service, so they are not stopped (like in the command mentioned above), and they can be unpaused with docker-compose unpause.
From Gerad answer, if you consider a container as running OS (e.g. Windows) those commands can be mapped to: