TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Introducing dumb-init, an init system for Docker containers

161 pointsby ckuehlover 9 years ago

11 comments

gnudover 9 years ago
The actual reason you really need a proper PID 1 is not explained in this post, but a couple of clicks away at [0]:<p><pre><code> &gt;[...] the init process must also wait for child processes to terminate, &gt;before terminating itself. &gt;If the init process terminates prematurely then all children are terminated uncleanly by the kernel. </code></pre> 0: <a href="https:&#x2F;&#x2F;blog.phusion.nl&#x2F;2015&#x2F;01&#x2F;20&#x2F;docker-and-the-pid-1-zombie-reaping-problem&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.phusion.nl&#x2F;2015&#x2F;01&#x2F;20&#x2F;docker-and-the-pid-1-zomb...</a>
评论 #10855351 未加载
评论 #10854904 未加载
stephen-mwover 9 years ago
Very nice! I see this as the next evolution to the phusion&#x27;s custom init system[0], which was created to solve largely the same problems.<p>I should be able to take Yelp&#x27;s dumb-init and add it easily to any linux container I want -- including things such as Alpine[1]<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;phusion&#x2F;baseimage-docker&#x2F;blob&#x2F;master&#x2F;image&#x2F;bin&#x2F;my_init" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;phusion&#x2F;baseimage-docker&#x2F;blob&#x2F;master&#x2F;imag...</a> [1] <a href="https:&#x2F;&#x2F;github.com&#x2F;gliderlabs&#x2F;docker-alpine" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gliderlabs&#x2F;docker-alpine</a>
评论 #10854844 未加载
akavelover 9 years ago
If I understand correctly, the main goal here can be summarized in the quote below:<p><i>&quot;The motivation: modeling Docker containers as regular processes</i><p><i>[...] we want processes to behave just as if they weren’t running inside a container. That means handling user input, responding the same way to signals, and dying when we expect them to. In particular, when we signal the docker run command, we want that same signal to be received by the process inside.&quot;</i><p>and that seems to me as the core reason why they can&#x27;t just use a simple init system (like e.g. runit I suppose?)
vikiomega9over 9 years ago
&gt; Having a shell as PID 1 actually makes signaling your process almost impossible. Signals sent to the shell won’t be forwarded to the subprocess, and the shell won’t exit until your process does. The only way to kill your container is by sending it SIGKILL (or if your process happens to die).<p>Noob question. Why is it impossible? You have the PID, no?
评论 #10854351 未加载
loxover 9 years ago
This looks to be an alternative <a href="https:&#x2F;&#x2F;github.com&#x2F;krallin&#x2F;tini" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;krallin&#x2F;tini</a>
评论 #10854042 未加载
DanielDentover 9 years ago
Another alternative, for what it&#x27;s worth: <a href="https:&#x2F;&#x2F;github.com&#x2F;rciorba&#x2F;pidunu" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rciorba&#x2F;pidunu</a><p>I&#x27;ve created an Ubuntu PPA packaging of it (<a href="https:&#x2F;&#x2F;launchpad.net&#x2F;~danieldent&#x2F;+archive&#x2F;ubuntu&#x2F;pidunu" rel="nofollow">https:&#x2F;&#x2F;launchpad.net&#x2F;~danieldent&#x2F;+archive&#x2F;ubuntu&#x2F;pidunu</a>) and you can see an example of it in use at: <a href="https:&#x2F;&#x2F;github.com&#x2F;DanielDent&#x2F;docker-powerdns" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DanielDent&#x2F;docker-powerdns</a><p>For situations involving multiple processes, there&#x27;s also <a href="https:&#x2F;&#x2F;github.com&#x2F;just-containers&#x2F;s6-overlay" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;just-containers&#x2F;s6-overlay</a><p>Example use: <a href="https:&#x2F;&#x2F;github.com&#x2F;DanielDent&#x2F;docker-nginx-ssl-proxy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DanielDent&#x2F;docker-nginx-ssl-proxy</a> (automated Let&#x27;s Encrypt SSL front-end)
loxover 9 years ago
If it&#x27;s such a straightforward fix, why isn&#x27;t it part of the docker core? I&#x27;d love to hear from the docker team why it&#x27;s not a concern for them. Presumably if it was they&#x27;d have addressed it by now.<p>From my own experience with docker in production, I&#x27;m yet to see any of the described scenarios crop up. Has anyone else, or is this solving an extreme edge case?
评论 #10853992 未加载
评论 #10854465 未加载
dpeduover 9 years ago
This is cool, but you can solve the same problem with a single line of bash<p><pre><code> trap &#x27;kill $(jobs -p)&#x27; EXIT</code></pre>
评论 #10857927 未加载
ivan_ahover 9 years ago
Is there any reason you wouldn&#x27;t run normal &quot;non-dumb&quot; init for this using<p><pre><code> CMD [&quot;&#x2F;sbin&#x2F;init&quot;, &quot;2&quot;] </code></pre> and start your app using init.d scripts or supervidord as usual?<p>I feel like logrotate, cron, etc, are worth having inside container no?
评论 #10854005 未加载
评论 #10854104 未加载
评论 #10854009 未加载
评论 #10854007 未加载
kttover 9 years ago
Reminds me of RancherOS that also have Docker running as PID 1: <a href="https:&#x2F;&#x2F;github.com&#x2F;rancher&#x2F;os#how-this-works" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rancher&#x2F;os#how-this-works</a>
anonbankerover 9 years ago
Another sign that systemd is not going to infect docker any time soon.