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:
commit
763f9e799b
1 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue