I'm playing around with LXC. My goal is to run a single process within a container and I'm now focusing on processes running within my container.

When I create a basic LXC template on ubuntu 12.04, I've got about ten processes running (including cron, ttys, init ...). When I do the same with docker or Heroku dynos (using ps -ef), I've got only the process I launched. This lead to 2 questions:

  • Docker doesn't use the lxc-create command. rootfs of the containers (I suppose) are custom images downloaded. How do they tweak this image to make it run only one process ?

  • Dynos on Heroku have only one process running (the one users intend to run) but support the automatic restart of the process if this one crashes. I know this is possible if the process is supervised by init or upstart, but that means that at least init should run within the dyno (and that's no the case). How do they achieve this ?

These questions are quite complex, I'm not looking for a detailed answer here but just general ideas on how this work.


You can find some basic instructions on creating a base image in the docker docs and have a look at the mkimage-scripts in the source code's contrib directory. What it boils down to is you use the debootstrap tool to create a ubuntu/debian root filesystem, tar this and import it into docker. An example for building a minimal ubuntu precise (12.04 LTS) image from scratch would be:

    debootstrap --verbose --variant=minbase --include='iproute,iputils-ping' --arch=amd64 precise /tmp/precise/ `curl -s http://mirrors.ubuntu.com/mirrors.txt | head -1` 

The last curl bit will pick a ubuntu mirror close to your machine's location, you can also simply pass a standard ubuntu mirror url - note that this mirror picked will now be hard-coded into your new images etc/apt/sources.list, so you might want to amend it before packaging by editing it according to this

The supervision of running processes within docker containers is something that is not the task of your containers themselves - they are just in charge of running any given command in an isolated environment. The daemon-management part should happen on your docker host machine, i.e. you could write an upstart job for each of your desired containers.

  • Late reply Thank you, I found the answer to my question a longtime ago: they have their own /sbin/init binary, containers doesn't go through the all init process, that is why ps -ef only shows one ps. – rmonjo Feb 16 '14 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.