[lxc-users] Start container from systemd

Mark Clarkson mark.clarkson at smorg.co.uk
Mon Mar 2 15:43:07 UTC 2015


lxc-autostart in a systemd unit works perfectly. The systemd unit has
the following configuration:

 ExecStartPre=/usr/bin/lxc-autostart -A
 ExecStart=/usr/bin/lxc-wait -n %i -s 'STOPPED'
 ExecStop=/usr/bin/lxc-autostart -A -s

lxc-start in a systemd unit starts, with the following configuration,
but cannot be stopped within the unit or manually (using 'lxc-stop -n
<name>'), except by 'kill -9 <lxc-start-pid>'. The control group
directory gets left behind in this case, and they start to build up
(name1, name1-1, name1-2 etc).

 ExecStart=/usr/bin/lxc-start -F -f /var/lib/lxc/ubtr1/config -n %i
 ExecReload=/usr/bin/lxc-restart -F -n %i
 ExecStop=/usr/bin/lxc-stop -n %i

The '-f' is required to stop the '/sbin/init missing' error.
The '-F' is required because lxc-wait doesn't work either.

To be able to use systemd all I can think of doing is hacking
lxc-autostart (or maybe even creating single container groups if that's
possible) as I don't know where to start to 'fix' lxc-start, and I
haven't got that much time.

Help!



More information about the lxc-users mailing list