[lxc-devel] Detecting a non-root container
Daniel Lezcano
daniel.lezcano at free.fr
Wed Apr 6 11:34:43 UTC 2011
On 04/05/2011 09:23 PM, Cyril Brulebois wrote:
> Hi LXC folks,
>
> from my bug report against udev, so that it doesn't try to start when
> running in a non-root container:
>
> Marco d'Itri<md at Linux.IT> (05/04/2011):
>> On Apr 05, Cyril Brulebois<kibi at debian.org> wrote:
>>
>>> from a quick glance, it looks like running udev in a linux
>>> container isn't supported, so I guess it might make sense to use a
>>> check similar to is_chrooted in its postinst to decide whether to
>>> start the daemon.
>> No objections, but please come back with a detection method which is
>> sanctioned by the LXC people.
> Could you please advise on the best way to detect running in a
> non-root container? It looks like grepping /proc/1/cgroup for :/$
> could be a way to determine that (as opposed to :/foo$ in a "foo"
> container). Can you please confirm?
I would not rely on that because lxc may evolve to not use the cgroup if
not present.
If you use upstart, you can check the 'container=lxc' env variable in
the udev init script in order to know if you are in a container.
Otherwise for sysvrc init, I don't know how to handle that.
Thanks
-- Daniel
More information about the lxc-devel
mailing list