Fix killing of unresponsive containers by adding init process
Created by: mrnugget
Fixes https://github.com/sourcegraph/sourcegraph/issues/15314
This adds the --init
flag to the docker run
command so that the
entrypoint process (bash
in our case) is started by a init process.
That fixes the behaviour of the interrupt signal simply having no
effect.
From what I could gather that's because PID 1 (which is the
--entrypoint
in a Docker container) is protected and cannot be killed.
But --init
is given the PID1 is an init process, which forwards the
signal to our entrypoint and kills it, exiting afterwards.
Resources:
- https://stackoverflow.com/questions/45718967/how-do-you-kill-a-docker-containers-default-command-without-killing-the-entire-c
- https://unix.stackexchange.com/questions/457649/unable-to-kill-process-with-pid-1-in-docker-container
- https://stackoverflow.com/questions/31538314/stopping-docker-container-from-inside