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

Passing --init to docker run #2719

Closed
hynek opened this issue Jun 17, 2017 · 14 comments · Fixed by #11331
Closed

Passing --init to docker run #2719

hynek opened this issue Jun 17, 2017 · 14 comments · Fixed by #11331

Comments

@hynek
Copy link
Contributor

hynek commented Jun 17, 2017

As of Docker 1.13, tini is part of docker engine. All you got to do it pass --init to docker run.

I think this would be very useful to support in Nomad, especially because it’s a common trap many people walk into (I’d even argue to make it default eventually).

Any chance of adding it? I understand you’re using the API and the bindings for that option might be missing?

@dadgar
Copy link
Contributor

dadgar commented Jun 20, 2017

@hynek Would love a PR for this!

@hynek
Copy link
Contributor Author

hynek commented Jul 1, 2017

So I did some research, because I just couldn’t find the --init option in any API offered.

But then I found a clue in https://docs.docker.com/engine/reference/run/

The default init process used is the first docker-init executable found in the system path of the Docker daemon process. This docker-init binary, included in the default installation, is backed by tini.

With some experimenting I found out that docker run --init will simply copy docker-init to /dev/init and use it to run the entrypoint.


Do you have any guidance on whether/how this could be implemented in Nomad?

@ThomasLohner
Copy link

Wouldn't it make sense to be able to pass an array of custom docker run args instead of implementing every single one? similar to arsg[] for command.

@hynek
Copy link
Contributor Author

hynek commented Aug 28, 2017

redacted brain fart

@hynek
Copy link
Contributor Author

hynek commented Aug 28, 2017

Wait no never mind I got confused for a minute. The "problem" is that nomad never passes any CLI args to docker, it uses its API. And certain args sadly aren't exposed by the API. --init being one of them.

@ThomasLohner
Copy link

I understand, in that case there's no other choice than implementing all the stuff.

@nathanhruby
Copy link

Looks like https://docs.docker.com/engine/api/v1.39/#operation/ContainerCreate indicates this is passable as part of the API now in recent docker engines.

@mlehner616
Copy link

Any word on adding support for this? Because node.js requires this flag to properly handle external signals, we're running into it as a limitation.

Reference: https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#handling-kernel-signals

@hynek
Copy link
Contributor Author

hynek commented Apr 27, 2019

FWIW, until it gets fixed, it's quite easy to simulate.

You just add something like this to your base images:

# Add Tini
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]

# Run your program under Tini
CMD ["/your/program", "-and", "-its", "arguments"]
# or docker run your-image /your/program ...

See https://github.com/krallin/tini

@nicolaevladescu
Copy link
Contributor

To add to @hynek's comment.

If you use Alpine Linux (latest stable 3.9) as your base image you get tini plus a static linked variant tini-static in the official repositories. You also have dumb-init, another minimal init system for containers.

@scalp42
Copy link
Contributor

scalp42 commented Jun 26, 2019

@hynek curious, could we just leverage Nomad artifact to download it and use entrypoint + cmd in the job pointing to the artifact?

@tgross tgross added this to Needs Roadmapping in Nomad - Community Issues Triage Feb 12, 2021
@tgross tgross removed this from Needs Roadmapping in Nomad - Community Issues Triage Mar 4, 2021
@surajthakur
Copy link

@tgross Will this be a feature anytime in nomad roadmap ?

@schmichael
Copy link
Member

This will ship in Nomad v1.2.0!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants