Philipp's Computing Blog

Success is about speed and efficiency

Start Linux Containers (LXC) at Startup

/etc/default/lxc

The built in possibility on Ubuntu / Debian is to change the configuration file /etc/default/lxc:

RUN=yes
CONF_DIR=/etc/lxc
CONTAINERS="vm0 vm1"

In this example, vm0 and vm1 are LXC configuration files stored or linked in /etc/lxc. These containers will be started at startup.

custom init script /etc/init.d/lxc

Instead of the init script shipping with Ubuntu and Debian, you can use a custom init script (/etc/init.d/lxc) as the one from this commit on github.com. It does not make use of /etc/default/lxc to set up the containers to be run at startup but a mark.

one more way: /etc/init.d/lxc-watchdog

/etc/init.d/lxc-watchdog on phbaer/lxc-tools checks for the file /var/lib/lxc/*/on_boot and starts any associated container at startup. It can also start/stop single lxc containers and print their status. Not much different is http://sysadmin-cookbook.rot13.org/#lxc_watchdog_sh.

resources