Skip to content

Commit

Permalink
docker-container: use /docker/buildx cgroup by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
djs55 committed Sep 29, 2021
1 parent f54de1e commit 98d23b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/reference/buildx_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Passes additional driver-specific options. Details for each driver:
- `docker-container`
- `image=IMAGE` - Sets the container image to be used for running buildkit.
- `network=NETMODE` - Sets the network mode for running the buildkit container.
- `cgroup-parent=CGROUP` - Sets the cgroup parent of the buildkit container.
- `cgroup-parent=CGROUP` - Sets the cgroup parent of the buildkit container. Defaults to `/docker/buildx`.
- Example:

```console
Expand Down
5 changes: 5 additions & 0 deletions driver/docker-container/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
Target: containerBuildKitRootDir,
},
},
Resources: container.Resources{
// Place all buildkit containers inside this cgroup so limits can be attached
// to all build activity on the host.
CgroupParent: "/docker/buildx",
},
}
if d.netMode != "" {
hc.NetworkMode = container.NetworkMode(d.netMode)
Expand Down

0 comments on commit 98d23b0

Please sign in to comment.