[lxc-users] how to determine if in LXD

Tycho Andersen tycho.andersen at canonical.com
Mon Aug 1 18:38:36 UTC 2016


On Mon, Aug 01, 2016 at 04:01:00PM +0200, tapczan wrote:
> Hello
> 
> There is an easy way to determine if I'm in LXC, content of file
> /proc/self/cgroup shows path with /lxc, eg:
> 
> 2:cpu:/lxc/host
> 
> However in LXD this rule is no longer valid:
> 
> 2:cpu:/
> 
> It looks like real host from that point of view.
> 
> So tools like chef OHAI have issue in determining virtualisation role
> and status.
> 
> Is there as easy way to determine if I'm inside LXD container?

Try `systemd-detect-virt` on systemd-based distros, or
`running-in-container` on upstart-based distros.

Tycho

> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users


More information about the lxc-users mailing list