From 7da007a5e60436e4df9812121f53d0509088b699 Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Tue, 10 Jul 2018 18:21:10 +0200 Subject: [PATCH] Improve detection of containerized environments - fix issue #1732 The code determining if Portus is running containerized is broken on Kubernetes because in this case PID 1 doesn't belong to the `docker` cgroup slice. That causes the code to invoke `hostnamectl`, that tries to access kdbus from within a container. That causes Rails to fail immediately. Signed-off-by: Flavio Castelli --- packaging/suse/portusctl/lib/constants.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packaging/suse/portusctl/lib/constants.rb b/packaging/suse/portusctl/lib/constants.rb index 13774c577..99b6f473f 100644 --- a/packaging/suse/portusctl/lib/constants.rb +++ b/packaging/suse/portusctl/lib/constants.rb @@ -4,7 +4,8 @@ # Checks whether it's running inside of a Docker container or not def dockerized? - File.read("/proc/1/cgroup").include?("docker") + cgroup = File.read("/proc/1/cgroup") + cgroup.include?("docker") || cgroup.include?("kubepod") end # This one is set by the bash wrapper we deliver with our RPM