Rex
Rex copied to clipboard
Request: Detect LXC virtualization type
From virt-what, lxc containers can be detected as follows. virt-what cites this documentation http://www.freedesktop.org/wiki/Software/systemd/ContainerInterface
if [ -e "${root}/proc/1/environ" ] &&
cat "${root}/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container='; then
echo lxc
fi
/proc/1/environ contains
TERM=linux^@container=lxc^@container_ttys=/dev/pts/0 /dev/pts/1^@