diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go index 2cdd5bf47c..c894d2a95f 100644 --- a/cmd/dockerd/daemon.go +++ b/cmd/dockerd/daemon.go @@ -284,17 +284,7 @@ func newRouterOptions(config *config.Config, d *daemon.Daemon) (routerOptions, e if err != nil { return opts, err } - cgroupParent := "docker" - useSystemd := daemon.UsingSystemd(config) - if useSystemd { - cgroupParent = "system.slice" - } - if config.CgroupParent != "" { - cgroupParent = config.CgroupParent - } - if useSystemd { - cgroupParent = cgroupParent + ":" + "docker" + ":" - } + cgroupParent := newCgroupParent(config) bk, err := buildkit.New(buildkit.Opt{ SessionManager: sm, Root: filepath.Join(config.Root, "buildkit"), diff --git a/cmd/dockerd/daemon_unix.go b/cmd/dockerd/daemon_unix.go index df51c3ef4b..7b03e28594 100644 --- a/cmd/dockerd/daemon_unix.go +++ b/cmd/dockerd/daemon_unix.go @@ -13,6 +13,7 @@ import ( "github.com/containerd/containerd/runtime/v1/linux" "github.com/docker/docker/cmd/dockerd/hack" "github.com/docker/docker/daemon" + "github.com/docker/docker/daemon/config" "github.com/docker/docker/libcontainerd/supervisor" "github.com/docker/libnetwork/portallocator" "golang.org/x/sys/unix" @@ -107,3 +108,18 @@ func wrapListeners(proto string, ls []net.Listener) []net.Listener { } return ls } + +func newCgroupParent(config *config.Config) string { + cgroupParent := "docker" + useSystemd := daemon.UsingSystemd(config) + if useSystemd { + cgroupParent = "system.slice" + } + if config.CgroupParent != "" { + cgroupParent = config.CgroupParent + } + if useSystemd { + cgroupParent = cgroupParent + ":" + "docker" + ":" + } + return cgroupParent +} diff --git a/cmd/dockerd/daemon_windows.go b/cmd/dockerd/daemon_windows.go index 11ff7da871..3b9ed9551f 100644 --- a/cmd/dockerd/daemon_windows.go +++ b/cmd/dockerd/daemon_windows.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + "github.com/docker/docker/daemon/config" "github.com/docker/docker/libcontainerd/supervisor" "github.com/sirupsen/logrus" "golang.org/x/sys/windows" @@ -83,3 +84,7 @@ func allocateDaemonPort(addr string) error { func wrapListeners(proto string, ls []net.Listener) []net.Listener { return ls } + +func newCgroupParent(config *config.Config) string { + return "" +}