Skip to content

Commit 21e50b8

Browse files
committed
builder: pass host-gateway IP as worker label
We missed a case when parsing extra hosts from the dockerfile frontend so the build fails. To handle this case we need to set a dedicated worker label that contains the host gateway IP so clients like Buildx can just set the proper host:ip when parsing extra hosts that contain the special string "host-gateway". Signed-off-by: CrazyMax <[email protected]>
1 parent ab60412 commit 21e50b8

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

builder/builder-next/controller.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/docker/docker/builder/builder-next/exporter/mobyexporter"
2020
"github.com/docker/docker/builder/builder-next/imagerefchecker"
2121
mobyworker "github.com/docker/docker/builder/builder-next/worker"
22+
wlabel "github.com/docker/docker/builder/builder-next/worker/label"
2223
"github.com/docker/docker/daemon/config"
2324
"github.com/docker/docker/daemon/graphdriver"
2425
units "github.com/docker/go-units"
@@ -95,6 +96,7 @@ func newSnapshotterController(ctx context.Context, rt http.RoundTripper, opt Opt
9596

9697
wo.GCPolicy = policy
9798
wo.RegistryHosts = opt.RegistryHosts
99+
wo.Labels = getLabels(opt, wo.Labels)
98100

99101
exec, err := newExecutor(opt.Root, opt.DefaultCgroupParent, opt.NetworkController, dns, opt.Rootless, opt.IdentityMapping, opt.ApparmorProfile)
100102
if err != nil {
@@ -325,6 +327,7 @@ func newGraphDriverController(ctx context.Context, rt http.RoundTripper, opt Opt
325327
Layers: layers,
326328
Platforms: archutil.SupportedPlatforms(true),
327329
LeaseManager: lm,
330+
Labels: getLabels(opt, nil),
328331
}
329332

330333
wc := &worker.Controller{}
@@ -411,3 +414,11 @@ func getEntitlements(conf config.BuilderConfig) []string {
411414
}
412415
return ents
413416
}
417+
418+
func getLabels(opt Opt, labels map[string]string) map[string]string {
419+
if labels == nil {
420+
labels = make(map[string]string)
421+
}
422+
labels[wlabel.HostGatewayIP] = opt.DNSConfig.HostGatewayIP.String()
423+
return labels
424+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package label
2+
3+
// Pre-defined label keys similar to BuildKit ones
4+
// https://github.com/moby/buildkit/blob/v0.11.6/worker/label/label.go#L3-L16
5+
const (
6+
prefix = "org.mobyproject.buildkit.worker.moby."
7+
8+
HostGatewayIP = prefix + "host-gateway-ip"
9+
)

0 commit comments

Comments
 (0)