mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
propagate the dockerd cgroup-parent config to buildkitd
Signed-off-by: Anda Xu <anda.xu@docker.com>
This commit is contained in:
parent
b0bc9f6518
commit
d52485c2f9
4 changed files with 26 additions and 12 deletions
|
@ -54,6 +54,7 @@ type Opt struct {
|
|||
Root string
|
||||
Dist images.DistributionServices
|
||||
NetworkController libnetwork.NetworkController
|
||||
DefaultCgroupParent string
|
||||
}
|
||||
|
||||
// Builder can build using BuildKit backend
|
||||
|
|
|
@ -102,7 +102,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
exec, err := newExecutor(root, opt.NetworkController)
|
||||
exec, err := newExecutor(root, opt.DefaultCgroupParent, opt.NetworkController)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
const networkName = "bridge"
|
||||
|
||||
func newExecutor(root string, net libnetwork.NetworkController) (executor.Executor, error) {
|
||||
func newExecutor(root, cgroupParent string, net libnetwork.NetworkController) (executor.Executor, error) {
|
||||
networkProviders := map[pb.NetMode]network.Provider{
|
||||
pb.NetMode_UNSET: &bridgeProvider{NetworkController: net},
|
||||
pb.NetMode_HOST: network.NewHostProvider(),
|
||||
|
@ -28,6 +28,7 @@ func newExecutor(root string, net libnetwork.NetworkController) (executor.Execut
|
|||
return runcexecutor.New(runcexecutor.Opt{
|
||||
Root: filepath.Join(root, "executor"),
|
||||
CommandCandidates: []string{"docker-runc", "runc"},
|
||||
DefaultCgroupParent: cgroupParent,
|
||||
}, networkProviders)
|
||||
}
|
||||
|
||||
|
|
|
@ -284,11 +284,23 @@ func newRouterOptions(config *config.Config, daemon *daemon.Daemon) (routerOptio
|
|||
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" + ":"
|
||||
}
|
||||
bk, err := buildkit.New(buildkit.Opt{
|
||||
SessionManager: sm,
|
||||
Root: filepath.Join(config.Root, "buildkit"),
|
||||
Dist: daemon.DistributionServices(),
|
||||
NetworkController: daemon.NetworkController(),
|
||||
DefaultCgroupParent: cgroupParent,
|
||||
})
|
||||
if err != nil {
|
||||
return opts, err
|
||||
|
|
Loading…
Add table
Reference in a new issue