[lxc-users] Start container from systemd

Mark Clarkson mark.clarkson at smorg.co.uk
Mon Mar 2 00:23:49 UTC 2015



Sent from my Sony Xperia™ smartphone

---- Serge Hallyn wrote ----

> Quoting Mark Clarkson (mark.clarkson at smorg.co.uk):
> > Hi,
> > Does anyone know if it possible to start a container from systemd? 
> > 
> > I'm using an Ubuntu Vivid host. I added a systemd unit:
> > 
> > |----------------------------------------
> >  [Unit]
> >  Description=Linux Container %I
> >  After=network.target
> > 
> >  [Service]
> >  Type=simple
> >  Restart=always
> >  ExecStart=/usr/bin/lxc-start -F -n ubtr1
> >  ExecReload=/usr/bin/lxc-restart -F -n %i
> >  ExecStop=/usr/bin/lxc-stop -n %i
> > 
> >  [Install]
> >  WantedBy=multi-user.target
> > |---------------------------------------
> 
> Hi,
> 
> Is there a reason you're not using autostart for this?  Does that
> fail also?

Lxc-autostart works fine, but I need systemd because I want to try Fleet and etcd with lxc. I want to have the choice to use docker and/or lxc in simple clusters. This is for a new build env where the architecture might be also used for production if it works well. 

> 
> I'm not claiming to know whether autostart is properly hooked in right
> now when you're running systemd :)  But if it's not we should fix that.

After much head scratching I used lxc-autostart, for a single container, started by systemd - so systemd calls lxc-autostart. That worked! Stopping it in systemd also worked. I had a quick look to see the differences in the code but saw nothing obvious. 

I was going to try the daily build to see if lxc-start is 'fixed' in the latest. Is that worth doing? 

> 
> > '/usr/bin/lxc-start -F -n ubtr1' works fine from the console.
> > 
> > 'systemctl start lxc at ubtr1' causes:
> > 
> >  lxc_start.c: main: 295 Executing '/sbin/init' with no configuration
> > file may crash the host
> > 
> > 'lxc-start -F -n ubtr1 -l trace -o debug.out' when started from systemd:
> > 
> >       lxc-start 1424876366.120 INFO     lxc_start_ui -
> > lxc_start.c:main:264 - using rcfile /var/lib/lxc/ ubtr1/config
> >       lxc-start 1424876366.120 WARN     lxc_log - log.c:lxc_log_init:316
> > - lxc_log_init called with log already initialized
> >       lxc-start 1424876366.154 WARN     lxc_cgmanager -
> > cgmanager.c:cgm_get:962 - do_cgm_get exited with error
> >       lxc-start 1424876366.155 ERROR    lxc_start_ui -
> > lxc_start.c:main:295 - Executing '/sbin/init' with no configuration file
> > may crash the host
> > 
> > I have also tried disabling apparmor and relaxing directory permissions
> > but still no joy. Someone please help me!
> > 
> > Thanks!
> > Mark
> > 
> > _______________________________________________
> > lxc-users mailing list
> > lxc-users at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-users
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20150302/6bdab1fa/attachment.html>


More information about the lxc-users mailing list