mirror of https://github.com/docker/buildx.git
docker-container: support --driver-opt cgroup-parent=...
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 commit is contained in:
parent
c643c2ca95
commit
b5bc754bad
|
@ -130,6 +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 if docker is using the "cgroupfs" driver.
|
||||
- Example:
|
||||
|
||||
```console
|
||||
|
|
|
@ -38,10 +38,11 @@ const (
|
|||
|
||||
type Driver struct {
|
||||
driver.InitConfig
|
||||
factory driver.Factory
|
||||
netMode string
|
||||
image string
|
||||
env []string
|
||||
factory driver.Factory
|
||||
netMode string
|
||||
image string
|
||||
cgroupParent string
|
||||
env []string
|
||||
}
|
||||
|
||||
func (d *Driver) IsMobyDriver() bool {
|
||||
|
@ -125,6 +126,11 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
|
|||
if d.netMode != "" {
|
||||
hc.NetworkMode = container.NetworkMode(d.netMode)
|
||||
}
|
||||
if info, err := d.DockerAPI.Info(ctx); err == nil && info.CgroupDriver == "cgroupfs" {
|
||||
if d.cgroupParent != "" {
|
||||
hc.CgroupParent = d.cgroupParent
|
||||
}
|
||||
}
|
||||
_, err := d.DockerAPI.ContainerCreate(ctx, cfg, hc, &network.NetworkingConfig{}, nil, d.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -49,6 +49,8 @@ func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver
|
|||
}
|
||||
case k == "image":
|
||||
d.image = v
|
||||
case k == "cgroup-parent":
|
||||
d.cgroupParent = v
|
||||
case strings.HasPrefix(k, "env."):
|
||||
envName := strings.TrimPrefix(k, "env.")
|
||||
if envName == "" {
|
||||
|
|
Loading…
Reference in New Issue