1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #40846 from AkihiroSuda/cgroup2-use-systemd-by-default

cgroup2: use "systemd" cgroup driver by default when available
This commit is contained in:
Brian Goff 2020-05-28 11:37:39 -07:00 committed by GitHub
commit 763f9e799b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -635,7 +635,23 @@ func VerifyCgroupDriver(config *config.Config) error {
// UsingSystemd returns true if cli option includes native.cgroupdriver=systemd
func UsingSystemd(config *config.Config) bool {
return getCD(config) == cgroupSystemdDriver
if getCD(config) == cgroupSystemdDriver {
return true
}
// On cgroup v2 hosts, default to systemd driver
if getCD(config) == "" && cgroups.IsCgroup2UnifiedMode() && IsRunningSystemd() {
return true
}
return false
}
// IsRunningSystemd is from https://github.com/opencontainers/runc/blob/46be7b612e2533c494e6a251111de46d8e286ed5/libcontainer/cgroups/systemd/common.go#L27-L33
func IsRunningSystemd() bool {
fi, err := os.Lstat("/run/systemd/system")
if err != nil {
return false
}
return fi.IsDir()
}
// verifyPlatformContainerSettings performs platform-specific validation of the