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鈥檚 a common trap many people walk into (I鈥檇 even argue to make it default eventually).
Any chance of adding it? I understand you鈥檙e using the API and the bindings for that option might be missing?
@hynek Would love a PR for this!
So I did some research, because I just couldn鈥檛 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?
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.
redacted brain fart
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.
I understand, in that case there's no other choice than implementing all the stuff.
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.
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
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 ...
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.
@hynek curious, could we just leverage Nomad artifact to download it and use entrypoint + cmd in the job pointing to the artifact?
Most helpful comment
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.