[lxc-users] how to determine if in LXD
Lago Gonzalez, Diego
diego.lago-gonzalez at hp.com
Tue Aug 2 09:59:42 UTC 2016
Hello,
There are several ways you can use to know if you are in an LXD container.
First of all, you can check if $container variable is defined inside a shell; and its contents. If so, you are in a container.
Other way is checking if /dev/lxd directory exists. That directory/device is created only if you are inside an LXD container.
Finally, you can use virt-what command (in Ubuntu, you can install it with apt).
Best regards.
—
Diego Lago
-----Mensaje original-----
De: lxc-users [mailto:lxc-users-bounces at lists.linuxcontainers.org] En nombre de Tycho Andersen
Enviado el: lunes, 01 de agosto de 2016 20:39
Para: LXC users mailing-list <lxc-users at lists.linuxcontainers.org>
Asunto: Re: [lxc-users] how to determine if in LXD
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
_______________________________________________
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