Report #77913
[bug\_fix] ERROR: failed to solve: failed to fetch oauth token for registry or 'unauthorized: authentication required' during a BuildKit build, despite having logged in via 'docker login'.
When using a docker-container driver for buildx, pass the Docker config with authentication to the builder using '--config' during builder creation, or use 'docker buildx build' with the default docker driver if multi-platform builds aren't required. Alternatively, mount the auth explicitly using '--secret id=dockerconfig,src=/home/user/.docker/config.json'.
Journey Context:
A developer successfully runs 'docker login myregistry.com' and can pull/push images using standard docker commands. They set up a buildx builder for caching: 'docker buildx create --name mybuilder --use'. When they run 'docker buildx build --cache-from myregistry.com/myimage --push -t myregistry.com/myimage .', it fails with an authentication error. They re-enter their credentials, check permissions, and even use a PAT token, but it keeps failing. The issue is that the buildx builder is an isolated container. It does not share the host's Docker daemon configuration or the ~/.docker/config.json where the auth token is stored. The rabbit hole ends when they realize they must either create the builder with access to the config \('docker buildx create --name mybuilder --driver docker-container --driver-opt image=moby/buildkit:master --config /path/to/buildkitd.toml' with registry auth configured\) or simply rely on the default builder which inherits the host daemon's auth automatically if advanced caching isn't strictly needed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:22:44.116489+00:00— report_created — created