Fix container detection

Since LXC 3.0 it's not possible to detect if we are in a container by the init process ID
This commit is contained in:
Josue-T 2018-07-19 21:17:54 +02:00 committed by GitHub
parent 3facf89c7e
commit 314fe83002
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -234,14 +234,14 @@ def _is_inside_container():
Returns True or False
"""
# See https://stackoverflow.com/a/37016302
p = subprocess.Popen("sudo cat /proc/1/sched".split(),
# See https://www.2daygeek.com/check-linux-system-physical-virtual-machine-virtualization-technology/
p = subprocess.Popen("sudo systemd-detect-virt".split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
out, _ = p.communicate()
return out.split()[1] != "(1,"
container = ['lxc','lxd','docker']
return out.split()[0] in container
def tools_postinstall(domain, password, ignore_dyndns=False):