Which one should i use? docker kill or docker stop?

前端 未结 3 620
[愿得一人]
[愿得一人] 2021-02-07 03:03

Will docker stop fail if processes running inside the container fail to stop?? If i use docker kill, can unsaved data inside the container be preserved

相关标签:
3条回答
  • 2021-02-07 03:11

    docker stop will send SIGTERM (terminate signal) to the process and docker will have 10 seconds to clean up like saving files or emitting some messages.

    Use docker kill when container is locked up, if it is not responding.

    0 讨论(0)
  • 2021-02-07 03:17

    You should use docker stop since it stops the container gracefully - like shutting down your laptop, instead of killing them - like forcibly turn off the laptop from it's battery.

    But, Docker will force shut down (kill the processes) by the time it takes 10 seconds to stop them gracefully.

    0 讨论(0)
  • 2021-02-07 03:22

    Line reference:

    docker stop: Stop a running container (send SIGTERM, and then SIGKILL after grace period) [...] The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. [emphasis mine]

    docker kill: Kill a running container (send SIGKILL, or specified signal) [...] The main process inside the container will be sent SIGKILL, or any signal specified with option --signal. [emphasis mine]

    You can get more info from this post: https://superuser.com/questions/756999/whats-the-difference-between-docker-stop-and-docker-kill

    0 讨论(0)
提交回复
热议问题