Linux reboots slower then a container is running

Since I started running a container on my torizoncore I can notice that when I run “sudo reboot now” from the linux terminal, it takes a few (~10 seconds) longer for it to start the reboot process. My container is running a python socket server that pretty much runs forever and I guess linux has to await to stop this container.

So this made me think: is there some flag that I can look for inside my container that tells me that linux is about to restart, so I can safely stop the server? I am very new to containers so any good practices around this topic are welcome!

Greetings @swiss,

When a reboot or shutdown command is given by the system all processes are sent a SIGTERM initially to prepare for the reboot/shutdown. For container processes this is more or less the same idea. See the thread here for a more in-depth explanation: linux - How does Docker handle a system shutdown? - Unix & Linux Stack Exchange

You should design your application to handle such signals so that a graceful shutdown can occur.

Best Regards,