Skip to content

Commit 0055cd2

Browse files
committed
build: improve error messages for docker driver
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent e5419ef commit 0055cd2

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

build/build.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
391391

392392
for _, e := range opt.CacheTo {
393393
if e.Type != "inline" && !nodeDriver.Features(ctx)[driver.CacheExport] {
394-
return nil, nil, notSupported(nodeDriver, driver.CacheExport)
394+
return nil, nil, cacheExportNotSupported(nodeDriver)
395395
}
396396
}
397397

@@ -529,7 +529,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
529529
// set up exporters
530530
for i, e := range opt.Exports {
531531
if e.Type == "oci" && !nodeDriver.Features(ctx)[driver.OCIExporter] {
532-
return nil, nil, notSupported(nodeDriver, driver.OCIExporter)
532+
return nil, nil, exporterNotSupported(nodeDriver, driver.OCIExporter)
533533
}
534534
if e.Type == "docker" {
535535
features := docker.Features(ctx, e.Attrs["context"])
@@ -555,7 +555,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
555555
opt.Exports[i].Output = wrapWriteCloser(w)
556556
}
557557
} else if !nodeDriver.Features(ctx)[driver.DockerExporter] {
558-
return nil, nil, notSupported(nodeDriver, driver.DockerExporter)
558+
return nil, nil, exporterNotSupported(nodeDriver, driver.DockerExporter)
559559
}
560560
}
561561
if e.Type == "image" && nodeDriver.IsMobyDriver() {
@@ -627,7 +627,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
627627
pp[i] = platforms.Format(p)
628628
}
629629
if len(pp) > 1 && !nodeDriver.Features(ctx)[driver.MultiPlatform] {
630-
return nil, nil, notSupported(nodeDriver, driver.MultiPlatform)
630+
return nil, nil, multiPlatformBuildNotSupported(nodeDriver)
631631
}
632632
so.FrontendAttrs["platform"] = strings.Join(pp, ",")
633633
}
@@ -771,7 +771,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
771771
for _, e := range dp.so.Exports {
772772
if e.Type == "moby" {
773773
if ok, _ := strconv.ParseBool(e.Attrs["push"]); ok {
774-
return nil, errors.Errorf("multi-node push can't currently be performed with the docker driver, please switch to a different driver")
774+
return nil, errors.Errorf("")
775775
}
776776
}
777777
}
@@ -1560,8 +1560,28 @@ func waitContextDeps(ctx context.Context, index int, results *waitmap.Map, so *c
15601560
return nil
15611561
}
15621562

1563-
func notSupported(d driver.Driver, f driver.Feature) error {
1564-
return errors.Errorf("%s feature is currently not supported for %s driver. Please switch to a different driver (eg. \"docker buildx create --use\")", f, d.Factory().Name())
1563+
func cacheExportNotSupported(d driver.Driver) error {
1564+
return errors.Errorf(`Cache export is currently not supported for the %s driver.
1565+
1566+
Switch to a different driver, or use inline cache, and try again.
1567+
1568+
Learn more at https://docs.docker.com/go/build-cache-backends/`, d.Factory().Name())
1569+
}
1570+
1571+
func exporterNotSupported(d driver.Driver, f driver.Feature) error {
1572+
return errors.Errorf(`%s is not currently supported for the %s driver.
1573+
1574+
Switch to a different driver, or a different output type, and try again.
1575+
1576+
Learn more at https://docs.docker.com/go/build-exporters/`, f, d.Factory().Name())
1577+
}
1578+
1579+
func multiPlatformBuildNotSupported(d driver.Driver) error {
1580+
return errors.Errorf(`Multi-platform builds is currently not supported for the %s driver without the containerd image store.
1581+
1582+
Switch to a different driver, or turn on the containerd image store, and try again.
1583+
1584+
Learn more at https://docs.docker.com/go/build-multi-platform/`, d.Factory().Name())
15651585
}
15661586

15671587
func noDefaultLoad() bool {

0 commit comments

Comments
 (0)