[Lxc-users] lxc-execute-ephemeral?

Serge Hallyn serge.hallyn at canonical.com
Fri Aug 24 12:37:16 UTC 2012


Quoting Dan Kegel (dank at kegel.com):
> On Thu, Aug 23, 2012 at 1:50 PM, Dan Kegel <dank at kegel.com> wrote:
> > On Thu, Aug 23, 2012 at 1:32 PM, Dan Kegel <dank at kegel.com> wrote:
> >> at the start of a build, use lxc-start-ephemeral -d to start the
> >> ephemeral container,
> >
> > It's somewhat annoying to parse out the name of the
> > ephemeral container from the log.  Is there a right
> > way to get it?  (Or can it be passed in as a parameter?)
> 
> Here's a little demo.  Please poke holes in it and tell me how to
> really do this :-)
> 
> #!/bin/sh
> sudo lxc-start-ephemeral -o test-container2 -d > log 2>&1
> while ! grep "is running" log
> do
>     sleep 1
> done
> container=`awk '/is running/ {print $1}' log`
> sudo chroot /var/lib/lxc/$container/rootfs touch /xyzzy
> sudo chroot /var/lib/lxc/$container/rootfs ls -l /xyzzy
> sudo lxc-stop --name $container

I think you're better off submitting a patch to make lxc-start-ephemeral
work better for you.  I.e. an option to have it print the container
name to a file, or have it optionally internally use lxc-console instead
of ssh, etc.  In other words you don't have to hack around its shortcomings,
feel free to address them instead.  Once you're sure exactly what you need.

-serge




More information about the lxc-users mailing list