Skip to content

Commit

Permalink
Merge pull request containers#3731 from giuseppe/fix-systemd-in-a-con…
Browse files Browse the repository at this point in the history
…tainer

cgroup: fix regression when running systemd
  • Loading branch information
openshift-merge-robot authored Aug 7, 2019
2 parents f0a5b7f + 69727ab commit 66ea32c
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
return err
}

g.RemoveMount("/sys/fs/cgroup")

if unified {
g.RemoveMount("/sys/fs/cgroup")

sourcePath := filepath.Join("/sys/fs/cgroup")
systemdMnt := spec.Mount{
Destination: "/sys/fs/cgroup",
Expand All @@ -483,31 +483,13 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
}
g.AddMount(systemdMnt)
} else {
// rootless containers have no write access to /sys/fs/cgroup, so don't
// add any mount into the container.
if !rootless.IsRootless() {
cgroupPath, err := c.CGroupPath()
if err != nil {
return err
}
sourcePath := filepath.Join("/sys/fs/cgroup", cgroupPath)

systemdMnt := spec.Mount{
Destination: "/sys/fs/cgroup",
Type: "bind",
Source: sourcePath,
Options: []string{"bind", "private"},
}
g.AddMount(systemdMnt)
} else {
systemdMnt := spec.Mount{
Destination: "/sys/fs/cgroup",
Type: "bind",
Source: "/sys/fs/cgroup",
Options: []string{"bind", "nodev", "noexec", "nosuid"},
}
g.AddMount(systemdMnt)
systemdMnt := spec.Mount{
Destination: "/sys/fs/cgroup/systemd",
Type: "bind",
Source: "/sys/fs/cgroup/systemd",
Options: []string{"bind", "nodev", "noexec", "nosuid"},
}
g.AddMount(systemdMnt)
}

return nil
Expand Down

0 comments on commit 66ea32c

Please sign in to comment.