1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-16 03:52:12 +02:00

more explicit error message for docker buildx context error

This commit is contained in:
Torsten Curdt 2023-11-02 22:35:36 +01:00 committed by Carlos Alexandro Becker
parent cb656a35ec
commit 49f39736ef
2 changed files with 15 additions and 0 deletions

View File

@ -235,6 +235,9 @@ files in that dir:
Previous error:
%w`, tmp, strings.Join(files, "\n "), err)
}
if isBuildxContextError(err.Error()) {
return fmt.Errorf(`docker buildx not set to default context\nPlease switch with 'docker context use default'\nLearn more at https://goreleaser.com/errors/docker-build`)
}
return err
}
@ -262,6 +265,10 @@ func isFileNotFoundError(out string) bool {
strings.Contains(out, ": not found")
}
func isBuildxContextError(out string) bool {
return strings.Contains(out, "buildx to switch to context")
}
func processImageTemplates(ctx *context.Context, docker config.Docker) ([]string, error) {
// nolint:prealloc
var images []string

View File

@ -17,6 +17,14 @@ its root, so you can just `COPY binaryname /bin/binaryname` and etc.
Bellow you can find some **don'ts** as well as what you should **do**.
## `use docker --context=default buildx to switch to context "default"`
The "default" context is a built-in context in "docker buildx", and it is automatically created. This context typically points to the local Docker environment and is used by default for building images. It has to be active for `goreleaser` to build images with "buildx".
You can switch to the default context using `docker context use default`.
This change should be persistant.
### Don't
Build the binary again.