Live data from Hacker News

Docker and the PID 1 zombie reaping problem

blog.phusion.nl

21–30 of 72 posts

Re: Docker and the PID 1 zombie reaping problem

#21

Why write your own mini-init instead of using something like supervisord?

Supervisord is not an init and must not be run as pid1, that's explicitly mentioned in its documentation[0]:

> It shares some of the same goals of programs like launchd, daemontools, and runit. Unlike some of these programs, it is not meant to be run as a substitute for init as “process id 1”.

There are micro-inits you could use instead though, s6 should be runnable as pid1 for instance.

[0] http://supervisord.org/index.html?highlight=init

Re: Docker and the PID 1 zombie reaping problem

#23
post #6

Earlier quoted context omitted.

It's trivial to write this program in C and it is a waste of memory to load up 50 MB of Python just to accomplish this simple task.

Actually, the Python process eats less than 5 MB of RAM. Most other stuff on the system eats more RAM. Writing my_init took much more time than you think, and I do not regret choosing Python. My_init not only handles process reaping, but also environment variable handling and bunch of other stuff. Writing text parsers in C is a huge pain (libc has no regexps that are as easy to use as Python). I do not oppose rewriti…

Fair enough, but for the record it's at least 10 MB (try starting up Python and import your list of modules).

The environment variable handling and other stuff could perhaps be handled in a separate bash-script (or Python), such that the scope of the actual reaper is sufficiently small (to use a lower-level language).

Re: Docker and the PID 1 zombie reaping problem

#24
post #6

Earlier quoted context omitted.

It's trivial to write this program in C and it is a waste of memory to load up 50 MB of Python just to accomplish this simple task.

Actually, the Python process eats less than 5 MB of RAM. Most other stuff on the system eats more RAM. Writing my_init took much more time than you think, and I do not regret choosing Python. My_init not only handles process reaping, but also environment variable handling and bunch of other stuff. Writing text parsers in C is a huge pain (libc has no regexps that are as easy to use as Python). I do not oppose rewriti…

libc does have regexps. http://pubs.opengroup.org/onlinepubs/009695399/functions/reg...

Re: Docker and the PID 1 zombie reaping problem

#25
post #5

Sysv heavyweight?

It's got a reasonable amount of stuff in it. The Debian version of sysvinit (v2.88) is about 10,000 lines of C code. Probably not a huge deal, but it does more than just reaping zombie processes, if that's really all you want.

The actual init command is only about 3000 lines, the rest is for auxiliary programs that you probably wouldn't need for Docker. And 10k lines is still tiny compared to Python :)

Re: Docker and the PID 1 zombie reaping problem

#27
post #6

Earlier quoted context omitted.

It's trivial to write this program in C and it is a waste of memory to load up 50 MB of Python just to accomplish this simple task.

Actually, the Python process eats less than 5 MB of RAM. Most other stuff on the system eats more RAM. Writing my_init took much more time than you think, and I do not regret choosing Python. My_init not only handles process reaping, but also environment variable handling and bunch of other stuff. Writing text parsers in C is a huge pain (libc has no regexps that are as easy to use as Python). I do not oppose rewriti…

Why not use already existing init? runit seems small enough: http://smarden.org/runit/

Or if you want small have a look here for minimal PID 1 "So how should init be done right?" http://ewontfix.com/14/

Re: Docker and the PID 1 zombie reaping problem

#28
I'm not sure writing yet another pid 1 tool is such a good idea. I have been using Docker in production for a few months now and I use supervisord as pid 1. I am able to hook it to most app servers (python,rails,etc) as well as rsyslogd . logging is a big pain on Docker, and you should think of your logging strategy before the pid 1. How are you rotating your logs and is your pid 1 restarting your app on failure? For us, supervisord does all that.

We run syslog and logrotate inside the container (using a volume) and it works fairly well for us. Plus supervisord comes with a pretty kickass tool - supervisorctl - and the conf file is fairly well documented.

Optimizing the RAM/CPU usage of supervisors and rsyslogd is not very critical - it doesn't use too much.

I actually learned a lot from baseimage - but dont know why they went with runit rather than supervisord.

Would really,really,REALLY love to learn to do thus with systemd.

EDIT: ahh.. forgot that their script was based on runit. My mistake - but dont think I will change over from supervisord anytime soon.

Re: Docker and the PID 1 zombie reaping problem

#29
I know this will cost me a lot of karma, but surely this is the point that you say, lets just use a hypervisor?

yes, I know its much easier to just use docker, but at the point that you have to write a new INIT, doesn't that strike you as time you used something thats not easy anymore?

Things like "make sure we don't loose syslog" make me shudder.

Yes supposedly there is an argument that docker is faster. However as a buildeng i've seen little evidence of that.

We use VMware with throwaway build disks. This means that a Dev can destroy a machine, once rebooted its back to a known default state.

the best part is that we have collectd on the vmware host, and the in the guest to collect metrics on CPU, mem and IO.

Because we have decent disks, and lots of memory, we don't hit any limitations. For heavy build we have NFS root'd servers with non persistant disks. much faster, and requires almost no thinking about.

Re: Docker and the PID 1 zombie reaping problem

#30
>“As long as a zombie is not removed from the system via a wait, it will consume a slot in the kernel process table, and if this table fills, it will not be possible to create further processes.”

To the author->

Do you know how many processes a kernel can handle ?

root@lisa2:~# cat /proc/sys/kernel/pid_max 32768

fyi.

Post reply on HN