[英]Gracefully stop docker container when shutting down Google Compute Engine VM
When I delete a GCE VM I need my docker container to get stopped gracefully before the VM shuts down.当我删除 GCE VM 时,我需要我的 docker 容器在 VM 关闭之前正常停止。
I am using Compute Engine Container Optimized OS (COS) and would expect my containers to be managed properly, but this is not what I am experiencing.我正在使用 Compute Engine Container Optimized OS (COS),并希望我的容器得到正确管理,但这不是我遇到的情况。
I tried a shutdown-script calling docker stop $(docker ps -a -q)
but it doesn't make a difference at all.我尝试了一个关闭脚本调用
docker stop $(docker ps -a -q)
但它根本没有任何区别。 I can see it runs, but it seems the container is already gone by then.我可以看到它在运行,但那时容器似乎已经消失了。
I've tried trapping SIGTERM in my application.我试过在我的应用程序中捕获 SIGTERM。 In the VM it's not trapping the signal, but on my local machine it does.
在虚拟机中它没有捕获信号,但在我的本地机器上它确实如此。
I am a bit lost and don't know what else to try.我有点迷路,不知道还能尝试什么。 Any idea?
任何的想法?
Take a look at Stopping Docker Containers Gracefully and also Gracefully Stopping Docker Containers看看正常停止 Docker 容器和正常停止 Docker 容器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.