Stop a running Docker container by sending SIGTERM

后端 未结 3 499
臣服心动
臣服心动 2020-12-11 02:36

I have a very very simple Go app listening on port 8080

http.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(200)
    w.He         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-11 03:01

    A very comprehensive description of this problem and the solutions can be found here: https://vsupalov.com/docker-compose-stop-slow

    In my case, my app expects to receive SIGTERM signal for graceful shutdown didn't receive it because the process started by a bash script which called from a dockerfile in this form: ENTRYPOINT ["/path/to/script.sh"]

    so the script didn't propagate the SIGTERM to the app. The solution was to use exec from the script run the command that starts the app: e.g. exec java -jar ...

提交回复
热议问题