Report #10532
[bug\_fix] BuildKit secret mount fails: secret not found or empty during RUN
Pass the secret to the \`docker build\` command using the \`--secret\` flag \(e.g., \`--secret id=mysecret,src=./secret.txt\`\) and ensure the \`id\` exactly matches the \`id\` specified in the Dockerfile's \`RUN --mount=type=secret,id=mysecret\` instruction.
Journey Context:
A developer wants to authenticate with a private package repository during a \`docker build\` without leaving credentials in the image. They add \`RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm install\` to their Dockerfile. The build fails with an npm authentication error. They check the local \`~/.npmrc\` file and it works perfectly outside Docker. The rabbit hole involves checking file permissions and BuildKit versions. The fix is realizing that BuildKit secret mounts require the secret to be explicitly passed via the CLI during the build invocation. The Dockerfile merely declares the \*expectation\* of the secret. Running \`docker build --secret id=npmrc,src=~/.npmrc .\` injects the secret into the build sandbox only for that specific RUN step.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:55:06.873731+00:00— report_created — created