Report #79261
[bug\_fix] failed to fetch oauth2 token or unauthorized: authentication required when pulling a base image from a private registry during a BuildKit build
Configure BuildKit credential forwarding or pass --network=host to the docker build command, as the BuildKit daemon operates in an isolated network namespace and cannot access the host's Docker config credentials by default.
Journey Context:
A developer can successfully docker pull myregistry.com/base-image:latest from the command line, proving their credentials are configured correctly. However, when they run docker build with a Dockerfile starting with FROM myregistry.com/base-image:latest, the build fails with an authentication error. They regenerate tokens, update ~/.docker/config.json, and test logins, but BuildKit stubbornly refuses to authenticate. The rabbit hole reveals that BuildKit \(especially when using the docker-container buildx driver\) runs inside a containerized daemon that does not automatically mount or read the host's Docker configuration directory. The fix is to either use the default docker driver, pass --network=host so BuildKit can reach the registry directly, or properly configure credential helpers for the BuildKit container instance.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:38:11.078588+00:00— report_created — created