It only requires you to prepend all commands with run
, then if the script process is TERM
, it will forward the signal
to the processes you instanciated using the run command if they are still alive, if they are not, they are just ignored.
This was designed to make docker containers shutdown faster when you have a starting script to run (in this example we are
running npm install
and npm start
), this works because when requested to stop the container, docker will send a TERM
signal to the process with id 1
, which is the first command ran by the CMD
(CMD ["this_command_here.sh"]
).
So if this script receives TERM
it will forward it leading every process to shutdown, so the container can die peacefully.
References: