docker init pid=1 and signal


I understand that my first process in my container will run as pid=1 and linux will ignore sigterm/sigint until I setup signal handler in my code (trap in bash script …).

My question is the time between the container start and bash install the signal handler, or if I do a exec at the end of my bash script, again the new application must setup a signal handler, there is a small time frame here where the sigterm/sigint signal can be ignored.

How to deal with that ? we need to catch the sigterm signel when docker stop us to do some cleanup before docker reap us with a sigkill.

There is no way to 'hold' the sigterm until I setup handler ?

After I setup handler in my bash docker entry point, does it 'free' sigterm/sigint in the kernel so when I do exec to switch to the real application process, I have no risk to lost sigterm before I setup again the signal handler ?

I try to play with stopsignal in my dockerfile but wasn't able to get good result.

(we had a case of docker run followed by a docker stop almost immediatly, and I don't want to lost the sigterm)

Can point me to the specific documentation on sigterm/sigint dropped in the kernel for pid=1 ?

I see two liner text here or there about that, but nobody can point me to the correct full documetation, kernel notes…


submitted by /u/CyrilDevOps
[link] [comments]
Source: Reddit