From 314fe830025035a777f36f76e3de7dd910028793 Mon Sep 17 00:00:00 2001 From: Josue-T Date: Thu, 19 Jul 2018 21:17:54 +0200 Subject: [PATCH] Fix container detection Since LXC 3.0 it's not possible to detect if we are in a container by the init process ID --- src/yunohost/tools.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index 05504a755..c1b76a748 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -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):