Docker Stop Signals Go to PID 1 Only, Not Every Container Process
A widespread belief holds that docker stop delivers SIGTERM to all processes in a container, but the signal actually goes only to the container's main process, PID 1. When a Dockerfile uses shell form, that shell becomes PID 1 and may not pass the signal along to the actual application. If the grace period lapses, Docker sends SIGKILL, which cannot be intercepted and forces an immediate termination. Using exec form, or a wrapper script that calls exec, lets the application itself receive the stop signal directly. Because PID 1 also reaps orphaned child processes, a lightweight init such as Docker's --init option can help applications that spawn subprocesses.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in