简体   繁体   中英

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.

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.

I tried a shutdown-script calling docker stop $(docker ps -a -q) but it doesn't make a difference at all. I can see it runs, but it seems the container is already gone by then.

I've tried trapping SIGTERM in my application. 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM