-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-container: place build containers in a separate cgroup #782
Conversation
I noticed that the buildkit code embedded in dockerd also does some setting up of a parent cgroup (originally added (extracted to a function later) in moby/moby@d52485c); cgroupParent := newCgroupParent(config) 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
}
For the last bullet, I'm looking at the daemon code that handles (custom) parent cgroups for containers, which seems to confirm that; https://github.com/moby/moby/blob/306fa44b7ca59282dc8695e6d169c5b25698d0cb/daemon/daemon_unix.go#L709-L714 if hostConfig.CgroupParent != "" && UsingSystemd(daemon.configStore) {
// CgroupParent for systemd cgroup should be named as "xxx.slice"
if len(hostConfig.CgroupParent) <= 6 || !strings.HasSuffix(hostConfig.CgroupParent, ".slice") {
return warnings, fmt.Errorf("cgroup-parent for systemd cgroup should be a valid slice named as \"xxx.slice\"")
}
} Wondering how to solve that
|
/cc @AkihiroSuda (perhaps you have some thoughts on the above) |
driver/docker-container/driver.go
Outdated
} | ||
if d.netMode != "" { | ||
hc.NetworkMode = container.NetworkMode(d.netMode) | ||
} | ||
if d.cgroupParent != "" { | ||
hc.CgroupParent = d.cgroupParent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, this should be set only when d.DockerAPI.Info().CgroupDriver == “cgroupfs”
This allows the parent cgroup to be customised, which allows resource limits to be imposed on build containers separately from "user" containers. Signed-off-by: David Scott <dave@recoil.org>
This allows resource limits to be applied to all builds on a host. For example to limit the total amount of CPU used by builds: https://medium.com/@asishrs/docker-limit-resource-utilization-using-cgroup-parent-72a646651f9d Signed-off-by: David Scott <dave@recoil.org>
98d23b0
to
d5908cd
Compare
Thanks, I've pushed an update which gates the setting on |
Previously build containers created by the
docker-container
driver were in the default parent cgroup, along with non-build containers. This made it hard to apply resource limits to all the builds on a machine.This PR adds a
--driver-opt cgroup-parent=CGROUP
to allow the cgroup to be customised. A default value of/docker/buildx
is set.