From 4ae92b846b45ac9ef02e9d19b5d9ddcb4ac05bf3 Mon Sep 17 00:00:00 2001 From: Julian Edwards Date: Thu, 16 Mar 2017 09:01:39 +1000 Subject: [PATCH] Make running_in_container work in more containers Instead of grepping for 'lxc' in /proc/1/cgroup, use systemd's features. This now at least also works in LXD containers. Change-Id: I35e807c26f0b1fbba83ddbe04cfb4901a7a95cbe --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 1aa7517a8a..4435f2de2f 100644 --- a/functions +++ b/functions @@ -666,7 +666,7 @@ function set_mtu { # running_in_container - Returns true otherwise false function running_in_container { - if grep -q lxc /proc/1/cgroup; then + if [[ $(systemd-detect-virt --container) == 'none' ]]; then return 0 fi