Skip to content
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

Use a proper init for Docker images #2498

Open
Blaisorblade opened this issue Aug 16, 2016 · 4 comments
Open

Use a proper init for Docker images #2498

Blaisorblade opened this issue Aug 16, 2016 · 4 comments

Comments

@Blaisorblade
Copy link
Collaborator

@borsboom wrote:

for the Docker case, maybe we should go back to having a separate 'init' process. We used to use phusion/baseimage's my_init in the containers but eliminated that for faster startup and compatibility with non-FP Complete-generated images. At that time we considered whether we should introduce our own extra 'init' process but decided to try without and see how it went.

I agree. IMHO Docker images should always use a proper init process. Even if you run GHC directly:

  • signal handling will be different without an init process (signals without handler will be ignored)
  • zombie processes won't be reaped
  • more stuff might go wrong.

Minimal init binaries include dumb-init (used in the past by @snoyberg) and tini (used by me). I'll favor the smallest/most portable/possibly statically linked one.
#2474 was about a container launched manually, but IIUC the issue is still there for Stack Docker containers (to verify).

@borsboom
Copy link
Contributor

borsboom commented Aug 16, 2016

I'd like to avoid needing the Docker image to contain anything special (like dumb-init or tini), because that makes it harder to use arbitrary images (like the official Haskell images). Also, in my experience, those init processes tend to interfere with Stack's somewhat complex re-launching of itself in a container (although I haven't tried either dumb-init or tini).

Rather, stack can act as its own init process (basically detect that it's pid 1 in a container and if so fork itself and let the original process just reap zombies).

@Blaisorblade
Copy link
Collaborator Author

Rather, stack can act as its own init process (basically detect that it's pid 1 in a container and if so fork itself and let the original process just reap zombies).

Are you describing existing code or suggesting that somebody writes it?

@borsboom
Copy link
Contributor

The code doesn't exist yet. It's what I was thinking of implementing.

@Blaisorblade
Copy link
Collaborator Author

Sounds doable though not immediate.
tini is ~500 lines of subtle C (which might have more than we need) (https://github.com/krallin/tini/blob/master/src/tini.c); dumb-init is ~300 lines (https://github.com/Yelp/dumb-init/blob/master/dumb-init.c). At least if all libraries have wrappers (which sounds plausible).

My 2 cents: I'd say make it a lib (exposing initMain :: IO ()) that can be linked in stack and used externally (with main = initMain), so this can be leveraged elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants