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

Christian Brauner christianvanbrauner at gmail.com
Fri Sep 18 20:33:15 UTC 2015


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?
> 
> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150918/4cbe45ff/attachment.sig>


More information about the lxc-devel mailing list