dotcloud/docker — pull request #2789 by jpoimboe (2013-11-20 18:27:57+00:00)
Title: Create a long-running dockerinit

NOTE: This is kind of a big feature, so please let me know if this doesn't yet belong in a PR, or if it needs more discussion on the mailing list. Also, the commits are already split up, but let me know if it makes sense to also split it up into multiple PRs.

If docker is going to work on libvirt-lxc (and thus be supported on RHEL), a long-running dockerinit is the only realistic way to achieve that (that I'm aware of it). But it also gives other benefits. Here's an excerpt from my email to the docker-dev mailing list:

The biggest challenges [when porting docker to libvirt-lxc] were:

- getting the exit code from the container
- getting separated stdout/stderr streams

Neither is supported by libvirt-lxc, so the only viable solution was to
create a long-running dockerinit which runs for the lifetime of the
container, with the container application as its child process. Docker
then communicates with dockerinit over a UNIX socket.

Having a long-running dockerinit has other advantages as well:

- Removes the need for a Ghost state since we can always reconnect to
the container for console connection, exit notification, and exit code
reporting, even after a docker daemon restart. This could even enable
getting rid of the docker daemon altogether, and doing everything
client-side.

- Moves a lot of code from the container backend plugins (e.g., lxc,
libvirt-lxc, ...) into the docker core where it can be shared, which
means more consistent behavior, better test coverage, simpler plugins.

/cc @alexlarsson @jpetazzo