goreleaser: docker build failed: exit status 1: ERROR: use `docker --context=default buildx` to switch to context "default"

What happened?

When I run goreleaser release, the process reaches the section with Docker image creation and an error appears:

docker build failed: failed to build gowebly/gowebly:latest-arm64: exit status 1: ERROR: use `docker --context=default buildx` to switch to context "default"

My .goreleaser.yml:

...

dockers:
  -
    id: '{{ .ProjectName }}_linux_amd64' # For GNU/Linux x86_64
    ids: [ default ]
    use: buildx
    skip_push: auto
    image_templates:
      - 'gowebly/{{ .ProjectName }}:latest-linux-amd64'
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-linux-amd64'
    build_flag_templates:
      - '--pull'
      - '--label=org.opencontainers.image.created={{ .Date }}'
      - '--label=org.opencontainers.image.title={{ .ProjectName }}'
      - '--label=org.opencontainers.image.revision={{ .FullCommit }}'
      - '--label=org.opencontainers.image.version={{ .Version }}'
      - '--platform=linux/amd64'
    push_flags:
      - '--tls-verify=false'
  -
    id: '{{ .ProjectName }}_linux_arm64' # For GNU/Linux ARM
    ids: [ default ]
    use: buildx
    skip_push: auto
    image_templates:
      - 'gowebly/{{ .ProjectName }}:latest-linux-arm64'
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-linux-arm64'
    build_flag_templates:
      - '--pull'
      - '--label=org.opencontainers.image.created={{ .Date }}'
      - '--label=org.opencontainers.image.title={{ .ProjectName }}'
      - '--label=org.opencontainers.image.revision={{ .FullCommit }}'
      - '--label=org.opencontainers.image.version={{ .Version }}'
      - '--platform=linux/arm64'
    push_flags:
      - '--tls-verify=false'
  -
    id: '{{ .ProjectName }}_darwin_amd64' # For Apple macOS x86_64
    ids: [ default ]
    use: buildx
    skip_push: auto
    image_templates:
      - 'gowebly/{{ .ProjectName }}:latest-darwin-amd64'
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-darwin-amd64'
    build_flag_templates:
      - '--pull'
      - '--label=org.opencontainers.image.created={{ .Date }}'
      - '--label=org.opencontainers.image.title={{ .ProjectName }}'
      - '--label=org.opencontainers.image.revision={{ .FullCommit }}'
      - '--label=org.opencontainers.image.version={{ .Version }}'
      - '--platform=darwin/amd64'
    push_flags:
      - '--tls-verify=false'
  -
    id: '{{ .ProjectName }}_darwin_arm64' # For Apple macOS ARM
    ids: [ default ]
    use: buildx
    skip_push: auto
    image_templates:
      - 'gowebly/{{ .ProjectName }}:latest-darwin-arm64'
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-darwin-arm64'
    build_flag_templates:
      - '--pull'
      - '--label=org.opencontainers.image.created={{ .Date }}'
      - '--label=org.opencontainers.image.title={{ .ProjectName }}'
      - '--label=org.opencontainers.image.revision={{ .FullCommit }}'
      - '--label=org.opencontainers.image.version={{ .Version }}'
      - '--platform=darwin/arm64'
    push_flags:
      - '--tls-verify=false'

docker_manifests:
  -
    name_template: 'gowebly/{{ .ProjectName }}:latest'
    skip_push: auto
    image_templates:
      - 'gowebly/{{ .ProjectName }}:latest-linux-amd64'
      - 'gowebly/{{ .ProjectName }}:latest-linux-arm64'
      - 'gowebly/{{ .ProjectName }}:latest-darwin-amd64'
      - 'gowebly/{{ .ProjectName }}:latest-darwin-arm64'
  -
    name_template: 'gowebly/{{ .ProjectName }}:{{ .Tag }}'
    skip_push: auto
    image_templates:
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-linux-amd64'
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-linux-arm64'
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-darwin-amd64'
      - 'gowebly/{{ .ProjectName }}:{{ .Tag }}-darwin-arm64'

...

How can we reproduce this?

  1. Clone project https://github.com/gowebly/gowebly
  2. Run goreleaser release
  3. See error

goreleaser version

GitVersion:    1.21.2
GitCommit:     26fed97a0defe4e73e3094cb903225d5445e5f0d
GitTreeState:  false
BuildDate:     2023-09-26T11:20:15Z
BuiltBy:       goreleaser
GoVersion:     go1.21.1
Compiler:      gc
ModuleSum:     h1:dgYtIS7aZlQuRMUMLCjDCOs4lWss85Oh60RDSO0rbWU=
Platform:      darwin/arm64

GoReleaser Check

  • goreleaser check shows no errors

Search

  • I did search for other open and closed issues before opening this

Supporter

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Additional context

$ docker-buildx version

github.com/docker/buildx v0.11.2 9872040b6626fb7d87ef7296fd5b832e8cc2ad17

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Or just run docker context use default before running GoReleaser.

ah, correct… okay, so we’ll need to fix this in another way, will take a proper look later

fixed in #4401, thanks @tcurdt !

maybe we could at least document this better though… if anyone wants to give a swing at PR-ing that 😄

I think I agree, playing with it in https://github.com/goreleaser/goreleaser/pull/4566

I think we could yeah, maybe search for that, and thrown an error with an URL pointing to a better explanation, like this one for example: https://goreleaser.com/errors/dirty/

@dunglas That would be too easy! (embarrassed sarcasm)

Thanks 😃

If the switch is persistent maybe there isn’t much to do in code really.

I think that if you could add --context=<the context name> to build_flag_templates it would work, but we probably need a better solution