Choose default-cgroup parent by cgroup driver
It's "/docker" for cgroupfs and "system.slice" for systemd. Fix #19140 Signed-off-by: Alexander Morozov <lk4d4@docker.com> Upstream-commit: c1cd45d547ef26cf988dc72d456430361dafcf08 Component: engine
This commit is contained in:
@ -146,14 +146,11 @@ func InitContainer(c *Command) *configs.Config {
|
||||
// This can be overridden later by driver during mount setup based
|
||||
// on volume options
|
||||
SetRootPropagation(container, mount.RPRIVATE)
|
||||
container.Cgroups.Parent = c.CgroupParent
|
||||
|
||||
// check to see if we are running in ramdisk to disable pivot root
|
||||
container.NoPivotRoot = os.Getenv("DOCKER_RAMDISK") != ""
|
||||
|
||||
// Default parent cgroup is "docker". Override if required.
|
||||
if c.CgroupParent != "" {
|
||||
container.Cgroups.Parent = c.CgroupParent
|
||||
}
|
||||
return container
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,6 @@ import (
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/daemon/execdriver"
|
||||
"github.com/docker/docker/daemon/execdriver/native/template"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
"github.com/docker/docker/pkg/pools"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
@ -90,7 +89,6 @@ func NewDriver(root string, options []string) (*Driver, error) {
|
||||
case "systemd":
|
||||
if systemd.UseSystemd() {
|
||||
cgm = libcontainer.SystemdCgroups
|
||||
template.SystemdCgroups = true
|
||||
} else {
|
||||
// warn them that they chose the wrong driver
|
||||
logrus.Warn("You cannot use systemd as native.cgroupdriver, using cgroupfs instead")
|
||||
|
||||
@ -9,9 +9,6 @@ import (
|
||||
|
||||
const defaultMountFlags = syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV
|
||||
|
||||
// SystemdCgroups indicates whether systemd cgroup implemenation is in use or not
|
||||
var SystemdCgroups = false
|
||||
|
||||
// New returns the docker default configuration for libcontainer
|
||||
func New() *configs.Config {
|
||||
container := &configs.Config{
|
||||
@ -40,7 +37,7 @@ func New() *configs.Config {
|
||||
{Type: "NEWUSER"},
|
||||
}),
|
||||
Cgroups: &configs.Cgroup{
|
||||
Parent: "/docker",
|
||||
ScopePrefix: "docker", // systemd only
|
||||
Resources: &configs.Resources{
|
||||
AllowAllDevices: false,
|
||||
MemorySwappiness: -1,
|
||||
@ -99,10 +96,5 @@ func New() *configs.Config {
|
||||
container.AppArmorProfile = "docker-default"
|
||||
}
|
||||
|
||||
if SystemdCgroups {
|
||||
container.Cgroups.Parent = "system.slice"
|
||||
container.Cgroups.ScopePrefix = "docker"
|
||||
}
|
||||
|
||||
return container
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user