openshift-s2i / s2i-aspnet

Source-to-Image template for ASP.NET applications
16 stars 23 forks source link

Use dumb-init as entrypoint #29

Open jperville opened 7 years ago

jperville commented 7 years ago

This PR wraps the container entrypoint with dumb-init. This allows proper management of external signals and zombie processes.

Without dumb-init, shell signals (such as SIGTERM) are not forwarded to the application, resulting in not being able to gracefully shutdown the application. As proof, if I run the s2i-aspnet-example application in foreground (docker run --name testme --rm -p 8080:8080 s2i-aspnet-example) and then in another console do a docker stop --time=120 testme I can see that the container takes approximately 2 minutes to stop, which means that it is not gracefully stopped. On the docker run console, I can see that the value of $? code is 137, which means that the container was killed with signal 9 (not graceful).

With dumb-init as ENTRYPOINT, the same tests ends up with a graceful shutdown, without having to wait 2 minutes. Container $? code is 0, successful.

Bonus: if the container is run in foreground with -ti argument, dumb-init will handle CTRL-C properly and gracefully shutdown the application (container $? code is 130, which means the process terminated with signal 2, upon receiving CTRL-C).