Report #12611
[bug\_fix] Authentication failure or empty file at /run/secrets/ during RUN --mount=type=secret
Ensure the secret is actually passed to the build command using \`docker build --secret id=mysecret,src=./secret.txt\` and that the \`id\` in the Dockerfile exactly matches the \`id\` in the CLI flag.
Journey Context:
To avoid baking private SSH keys or API tokens into the image, a developer uses BuildKit's \`RUN --mount=type=secret,id=sshkey ...\` syntax. The build step that requires authentication fails. They add a debug step \`cat /run/secrets/sshkey\` and find it's empty or missing. They go down a rabbit hole checking file permissions on the host, trying different mount targets, and suspecting BuildKit bugs. The actual root cause is simply forgetting to pass the \`--secret\` flag to the \`docker build\` command itself, or a typo between the \`id\` in the Dockerfile and the \`id\` in the CLI. BuildKit does not fail the build if the secret is missing; it just mounts an empty directory or skips it, causing the subsequent authentication step to fail silently.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:25:44.427877+00:00— report_created — created