Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Improve detection of containerized environments - fix issue #1732
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
flavio committed Jul 10, 2018
1 parent 0583e1a commit 7da007a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packaging/suse/portusctl/lib/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7da007a

Please sign in to comment.