-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix killing of unresponsive containers by adding init process #369
Conversation
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call 1 800 555 5555 for Thorsten Ball container extermination services.
This is a campaign spec to reproduce the issue: name: sleep
description: sleep
on:
- repositoriesMatchingQuery: repo:automation-testing count:1
steps:
- run: sleep 40
container: alpine:3
changesetTemplate:
title: SLEEP
body: SLEEP
branch: campaign/sleep
commit:
message: Sleep
published: false This couldn't be killed before with Ctrl-C, now it does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I'm going to merge this once #368 lands so I can do a release.
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
Fixes https://github.com/sourcegraph/sourcegraph/issues/15314
This adds the
--init
flag to thedocker run
command so that theentrypoint 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 thesignal to our entrypoint and kills it, exiting afterwards.
Resources: