What is PID 1 in a container and why does it matter?
IntermediateConceptContainers, VMs & Isolation Internals
Answer
The first process in the PID namespace is PID 1. The kernel treats it specially: signals without a handler installed are ignored for PID 1 (so SIGTERM does nothing unless the app handles it), and PID 1 is expected to reap orphaned zombie children. Shell-form CMD makes /bin/sh PID 1, which does not forward signals. Use exec form or docker run --init (tini).
More on Containers, VMs & Isolation Internals
What is a container, in one sentence?BeginnerHow do containers differ from virtual machines?BeginnerCan a Linux container run a Windows application, or the reverse?IntermediateWhat are Linux namespaces? Name the ones Docker uses.BeginnerWhat are cgroups and what do they do for containers?BeginnerHow do you see which namespaces a container uses and enter them from the host?Intermediate