[Lxc-users] Howto detect we are in LXC contener

Ulli Horlacher framstag at rus.uni-stuttgart.de
Thu May 26 05:29:03 UTC 2011


On Thu 2011-05-26 (01:51), David Touzeau wrote:

> But i did not find any information inside the LXC contener in order to
> detect We are really in an LXC contener.

My trick is to mount cgroup into the container at /lxc/cgroup:

root at vms2:/lxc# grep cgroup flupp.fstab
/cgroup/flupp           /lxc/flupp/lxc/cgroup           none bind,ro 0 0

root at vms2:/lxc# mount | grep cgroup
none on /cgroup type cgroup (rw)

root at vms2:/lxc# lxc-console -n flupp
Type <Ctrl+a q> to exit the console
root at flupp:~# mount | grep cgroup
none on /lxc/cgroup type cgroup (ro,relatime,net_cls,freezer,devices,memory,cpuacct,cpu,ns,cpuset)

-- 
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