Report #8230
[bug\_fix] ERROR: failed to solve: failed to compute cache key: failed to authorize: failed to fetch anonymous token
Pass the host network to the BuildKit builder using --network=host during docker buildx create \(e.g., --driver-opt network=host\), or ensure the Docker config with registry credentials is mounted into the builder container.
Journey Context:
A developer has a multi-stage Dockerfile that pulls from a private registry \(e.g., COPY --from=ghcr.io/my-org/base-image ...\). It builds perfectly on their local machine. When moving to CI, the build fails with an authorization error, even though they logged in using docker login just steps before. They verify the credentials are correct and try different token formats. The issue is that BuildKit runs inside a docker-container driver by default in CI. This container is isolated from the host's network and filesystem. It cannot reach the local Docker socket or the host's ~/.docker/config.json where the auth tokens are stored, and it might not be able to resolve internal DNS for private registries. Using --driver-opt network=host allows the BuildKit container to use the host's network and credential helpers, resolving the auth failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:59:52.459742+00:00— report_created — created