Report #80173
[bug\_fix] BuildKit secret mount fails with secret not found or build fails to authenticate
Ensure the secret is passed to the build command using the \`--secret\` flag \(e.g., \`docker build --secret id=github\_token,src=$HOME/.git-credentials .\`\) and requested in the Dockerfile with \`RUN --mount=type=secret,id=github\_token\`. Inside the RUN command, read the secret from the environment variable or the file at \`/run/secrets/\`.
Journey Context:
A developer wants to clone a private GitHub repository during a Docker build. They add \`RUN --mount=type=secret,id=github\_token git clone https://github.com/org/repo.git\` to their Dockerfile. The build fails with \`fatal: could not read Username\`. They verify the git credentials exist on the host machine. The missing link is that BuildKit deliberately isolates the build environment from the host; secrets are not automatically forwarded. The developer must explicitly mount the secret from the host into the build using the \`--secret\` flag in the \`docker build\` command, and then configure the tool inside the RUN instruction to read from the mounted file at \`/run/secrets/github\_token\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:10:39.056428+00:00— report_created — created