Skip to content

Commit

Permalink
Merge pull request #4004 from giuseppe/fix-private-cgroup-systemd
Browse files Browse the repository at this point in the history
linux: fix systemd with --cgroupns=private
  • Loading branch information
openshift-merge-robot authored Sep 12, 2019
2 parents afa3d11 + a249c98 commit 2de4987
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2de4987

Please sign in to comment.