Report #45380
[bug\_fix] RUN --mount=type=secret fails to access the secret or build fails with secret not found
Pass the secret to the \`docker build\` command using \`--secret id=mysecret,src=./secret.txt\` and ensure \`DOCKER\_BUILDKIT=1\` is set \(or use \`docker buildx build\`\).
Journey Context:
A developer adds \`RUN --mount=type=secret,id=mytoken ...\` to their Dockerfile to securely download a private package. The build fails with an error indicating the secret is missing or the download gets an authentication error. They check the file on their host and it exists. The rabbit hole begins: they try different formats, check permissions, and eventually realize that just defining the mount in the Dockerfile is not enough. BuildKit requires the client to explicitly forward the secret during the build invocation. Without the \`--secret\` flag in the \`docker build\` command, BuildKit refuses to mount it, preventing accidental leaks. The fix works because it completes the required client-to-daemon secret handshake.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:38:34.558644+00:00— report_created — created