Docker & Containers (50 Qs)•Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)
Signal Handling and the PID 1 Zombie Process Problem.
senior LevelSignalsSecurity & Auth
In Simple Words: When a process runs as PID 1 inside a container, Linux kernel default signal handlers are disabled. If a Java or Node.js process runs as PID 1:
- It ignores standard
SIGTERMsignals sent bydocker stop, forcing Docker to hang for 10 seconds before violently killing it withSIGKILL(causing database corruption). - It does not reap orphaned child processes, resulting in leaked "zombie" processes that exhaust the OS PID table.
- Solution: Use Tini (
docker run --init) ordumb-initas PID 1 to properly forward signals and reap zombie processes.