[lxc-devel] lxc-start-ephemeral: passing a command

Serge Hallyn serge.hallyn at ubuntu.com
Mon Sep 21 15:17:37 UTC 2015


Quoting Christian Brauner (christianvanbrauner at gmail.com):
> On Fri, Sep 18, 2015 at 06:08:30PM +0200, Christian Brauner wrote:
> > When using lxc-start-ephemeral with a command that is supposed to be run in the
> > container:
> > 
> >         lxc-start-ephemeral -o aa /bin/sh
> > 
> > What is the expected behaviour:
> > 
> >         1) Start the container with its normal init process and then run the
> >            command in the container?
> >         2) Start the container with just the command running in the container
> >            i.e. similar to lxc-start -n aa -F /bin/sh?

Oh, when I first saw this I thought you were asking about lxc-start vs
lxc-execute, not fg vs bg.

> > I cannot test this since lxc-start-ephemeral does not work (don't know why yet)
> > on my system. I need to know to think of strategies how to implement this in C.
> > Option 1) seems kind of hard and I don't know how to smoothly implement this.
> > 
> > Christian
> 
> The best option seems to be to daemonize the container using
> 
>         c->want_daemonize(c, true);
> 
> starting it
> 
>         c->start(c, 0, NULL);
> 
> then calling
> 
>         c->attach_run_wait(c, /* and so on */);
> 
> to run the command in the container.

Right, since we're making 'ephemeral' a direct property of the container, we
can distinguish the same way as we do for regular containers.  For both fg/bg
and use_init=0/1.

-serge


More information about the lxc-devel mailing list