Skip to content

Signals and PID 1: why docker stop takes 10 seconds

Select an icon to see what it is.

Step 3 of 6

Shell form can leave a shell as PID 1

A shell-form CMD such as CMD ./setup.sh && ./app runs as /bin/sh -c. With two commands the shell usually stays alive as PID 1 and starts the app as its child. The shell does not forward SIGTERM, so the app never hears it.

Process tree inside the container

PID 1 /bin/sh -c ./setup.sh && ./app
PID 7 \_ ./app