summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-12 18:51:55 +0200
committerGitHub <noreply@github.com>2019-09-12 18:51:55 +0200
commit2de49870861be00cbd92108a1642796170a0aad1 (patch)
treec53a95ba0dd7e5e198ad16eb1e4a192aab9443e3
parentafa3d11381eb23820c653c44d3d249041bc6a833 (diff)
parenta249c98db8269186a2a5eec7e209979940ee77ef (diff)
downloadpodman-2de49870861be00cbd92108a1642796170a0aad1.tar.gz
podman-2de49870861be00cbd92108a1642796170a0aad1.tar.bz2
podman-2de49870861be00cbd92108a1642796170a0aad1.zip
Merge pull request #4004 from giuseppe/fix-private-cgroup-systemd
linux: fix systemd with --cgroupns=private
-rw-r--r--libpod/container_internal_linux.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 9f16389e6..4bbbef5db 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -491,12 +491,29 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
if unified {
g.RemoveMount("/sys/fs/cgroup")
- sourcePath := filepath.Join("/sys/fs/cgroup")
- systemdMnt := spec.Mount{
- Destination: "/sys/fs/cgroup",
- Type: "bind",
- Source: sourcePath,
- Options: []string{"bind", "private", "rw"},
+ hasCgroupNs := false
+ for _, ns := range c.config.Spec.Linux.Namespaces {
+ if ns.Type == spec.CgroupNamespace {
+ hasCgroupNs = true
+ break
+ }
+ }
+
+ var systemdMnt spec.Mount
+ if hasCgroupNs {
+ systemdMnt = spec.Mount{
+ Destination: "/sys/fs/cgroup",
+ Type: "cgroup",
+ Source: "cgroup",
+ Options: []string{"private", "rw"},
+ }
+ } else {
+ systemdMnt = spec.Mount{
+ Destination: "/sys/fs/cgroup",
+ Type: "bind",
+ Source: "/sys/fs/cgroup",
+ Options: []string{"bind", "private", "rw"},
+ }
}
g.AddMount(systemdMnt)
} else {