Report #52948
[bug\_fix] fatal: could not read Username for 'https://github.com': terminal prompts disabled \(or similar auth failure during RUN step\)
Pass the secret to the docker build command using --secret id=,src= and mount it in the Dockerfile using RUN --mount=type=secret,id= while reading the secret from /run/secrets/.
Journey Context:
A developer needs to clone a private Git repository during a Docker build. They try passing the token as a build argument \(--build-arg GIT\_TOKEN=...\), but this bakes the secret into the image history, which is a security risk. They switch to BuildKit's --mount=type=secret, adding RUN --mount=type=secret,id=git\_token git clone ... to the Dockerfile. The build still fails with an auth error. The developer realizes they forgot to actually pass the secret from the host during the docker build command. BuildKit requires a two-part handshake: the Dockerfile must mount the secret, AND the CLI must explicitly provide it via the --secret flag. Adding --secret id=git\_token,src=$HOME/.git-token to the docker build command securely injects the secret into the build step without persisting it in the final image layers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:22:14.804202+00:00— report_created — created