mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
Merge pull request #1761 from giuseppe/rootless-systemd
rootless: don't bind mount /sys/fs/cgroup/systemd in systemd mode
This commit is contained in:
@ -360,19 +360,31 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
|
|||||||
g.AddMount(tmpfsMnt)
|
g.AddMount(tmpfsMnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroupPath, err := c.CGroupPath()
|
// rootless containers have no write access to /sys/fs/cgroup, so don't
|
||||||
if err != nil {
|
// add any mount into the container.
|
||||||
return err
|
if !rootless.IsRootless() {
|
||||||
}
|
cgroupPath, err := c.CGroupPath()
|
||||||
sourcePath := filepath.Join("/sys/fs/cgroup/systemd", cgroupPath)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sourcePath := filepath.Join("/sys/fs/cgroup/systemd", cgroupPath)
|
||||||
|
|
||||||
systemdMnt := spec.Mount{
|
systemdMnt := spec.Mount{
|
||||||
Destination: "/sys/fs/cgroup/systemd",
|
Destination: "/sys/fs/cgroup/systemd",
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: sourcePath,
|
Source: sourcePath,
|
||||||
Options: []string{"bind", "private"},
|
Options: []string{"bind", "private"},
|
||||||
|
}
|
||||||
|
g.AddMount(systemdMnt)
|
||||||
|
} else {
|
||||||
|
systemdMnt := spec.Mount{
|
||||||
|
Destination: "/sys/fs/cgroup/systemd",
|
||||||
|
Type: "bind",
|
||||||
|
Source: "/sys/fs/cgroup/systemd",
|
||||||
|
Options: []string{"bind", "nodev", "noexec", "nosuid"},
|
||||||
|
}
|
||||||
|
g.AddMount(systemdMnt)
|
||||||
}
|
}
|
||||||
g.AddMount(systemdMnt)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user