简体   繁体   English

关闭 Google Compute Engine VM 时优雅地停止 docker 容器

[英]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?任何的想法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Compute Engine (GCE) 启动脚本 //“apt-get upgrade”关闭 google script runner (google-startup-scripts.service) - Google Compute Engine (GCE) Startup Script // "apt-get upgrade" shutting down google script runner (google-startup-scripts.service) 在 Google Compute Engine VM 中运行多服务 docker 撰写脚本 - Running a Multi-service docker compose script in Google Compute Engine VM 从计算引擎 vm 上的 Jenkins 脚本管道中的谷歌容器注册表中提取 - Pulling from google container registry in Jenkins scripted pipeline on compute engine vm Google Compute Engine VM 实例卡在暂存阶段 - Google Compute Engine VM instance stuck in staging 谷歌计算引擎无法访问虚拟机 - Google Compute Engine Unable to Access VM 重命名 Google Compute Engine VM 实例 - Rename Google Compute Engine VM Instance docker-compose.yml 在单个 Google Compute Engine VM 上指定的多个服务 - Multiple Services Specified by docker-compose.yml on a Single Google Compute Engine VM Google Compute Engine:无法通过 http 请求访问正在运行的 Docker 容器 - Google Compute Engine: Can't access running Docker container through http request 无法 SSH 进入我在 Google Cloud 上的 Compute Engine 虚拟机实例 - Unable to SSH into my Compute Engine VM instance on Google Cloud 删除谷歌计算引擎虚拟机中的度量事件文件是否安全 - Is it safe to delete metric events file in google compute engine vm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM