Report #3289
[bug\_fix] RUN --mount=type=secret fails to expose the secret or reads empty
Ensure the \`id\` provided to the Dockerfile \`RUN --mount=type=secret,id=...\` exactly matches the \`id\` passed in the \`docker build --secret id=...,src=...\` command, and access the secret via the standard \`/run/secrets/\` path.
Journey Context:
A developer tries to securely pass a GitHub PAT to clone a private repo during a build. They run \`docker build --secret id=git\_token,src=./token.txt .\` and in the Dockerfile use \`RUN --mount=type=secret,id=github\_token git clone ...\`. The mount fails silently or the clone fails with authentication errors. The developer assumes the file isn't being read, trying different file permissions and formats. The actual root cause is an ID mismatch: \`git\_token\` vs \`github\_token\`. BuildKit binds the host secret to the mount point in the container strictly using the \`id\` parameter. If the IDs don't match, the secret is never mounted into the container's \`/run/secrets/\` directory. Aligning the IDs exactly resolves the authentication failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T16:19:19.988345+00:00— report_created — created