hilbert / hilbert-docker-images

Application with a dynamic choice of docker containers to run
Apache License 2.0
22 stars 8 forks source link

Implement proper trap handling for all shell scripts #62

Open porst17 opened 6 years ago

porst17 commented 6 years ago

Shell scripts usually don't forward signals to their children. It needs to be implemented separately.

Signal handling is important for docker(-compose) stop and docker(-compose) rm --stop. If processes in the container do not properly handle SIGTERM, containers cannot be stopped until a certain timeout that triggers a SIGKILL (which should be avoided).

It is also important to check that the main process of a container is not executed in a separate shell by docker, i.e. CMD ["executable","param1","param2"] (or CMD ["param1","param2"] with a proper signal-handling ENTRYPOINT script) should be used instead of CMD command param1 param2 (which executes CMD via sh -c).