[Lxc-users] Executing a command inside a running container?

Ulli Horlacher framstag at rus.uni-stuttgart.de
Sun May 22 08:17:15 UTC 2011


On Sat 2010-01-30 (14:20), Dominik Schulz wrote:

> I'm fairly new to LXC and I am looking for a way to execute a command inside a 
> running container (a full blow one with its own rootfs and full isolation). 
> lxc-execute doesn't seem to do the trick and lxc-console requires credential 
> to login. 

It is not lxc-console which needs authentifcation, but it is login spawned
from the getty on the virtual console.

I found it useless to enter username/password via lxc-console, so I
changed the tty daemon process inside the Ubuntu container to:

  root at vms2:/lxc# cat /lxc/ubuntu/etc/init/tty1.conf 
  # tty1 - root shell 
  #
  # This service opens root shell on tty1

  start on stopped rc RUNLEVEL=[2345]
  stop on runlevel [!2345]

  respawn
  exec /bin/openvt -elfc 1 -- su -l


But you cannot give an command argument to lxc-console. It is for
interactive use only.

Therefore I have written lxc (*) which talks to lxc-cmdd inside the container
which then executes the command. Example:

  root at vms2:/lxc# uname -a
  Linux vms2 2.6.32-31-server #61-Ubuntu SMP Fri Apr 8 19:44:42 UTC 2011 x86_64 GNU/Linux

  root at vms2:/lxc# lxc -x vmtest8 uname -a
  Linux vmtest8 2.6.32-31-server #61-Ubuntu SMP Fri Apr 8 19:44:42 UTC 2011 x86_64 GNU/Linux


(*) http://fex.rus.uni-stuttgart.de/download/lxc


-- 
Ullrich Horlacher              Server- und Arbeitsplatzsysteme
Rechenzentrum                  E-Mail: horlacher at rus.uni-stuttgart.de
Universitaet Stuttgart         Tel:    ++49-711-685-65868
Allmandring 30                 Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.rus.uni-stuttgart.de/




More information about the lxc-users mailing list