[lxc-devel] execute commands in a RUNNING container

Daniel Lezcano daniel.lezcano at free.fr
Mon Sep 14 08:41:43 UTC 2009

Christophe Varoqui wrote:
> Hi,
> I could use a tool like zlogin to execute root commands inside a running
> container from the "global", without login challenge.
> Are "lxc-{execute,start} -n name -- cmd" supposed to do that ? In my
> testing, those report a "container busy" error.

No, the lxc-execute/lxc-start are for starting a container.

the lxc-execute launch an application without booting a full system. So 
a specific reaper has to be spawned between the command and the 
application in order to reap the child processes and to support the 
daemon (the pid namespace implementation makes it to kill all the 
processes of the container when the pid <1> exits.).

the lxc-start is for launching a system in the container, which does not 
launch this specific lxc-init process.

For example, you do:

lxc-create -n foo

lxc-execute -n foo -- bash -c 'echo $$'
returns '2'

lxc-start -n foo -- bash -c 'echo $$'
returns '1'

You are referring to a command which allows to 'enter' the container. 
There is actually a code in a branch <forker> with the command lxc-enter 
and lxc-exec I did not yet merged because of leak of time and a specifc 
configuration case I have to resolve before.

   -- Daniel

More information about the lxc-devel mailing list