Report #87386
[bug\_fix] RUN --mount=type=secret fails to authenticate or find the secret file inside the RUN command
Pass the secret to the build command using \`--secret id=,src=\` \(e.g., \`docker build --secret id=ssh,src=~/.ssh/id\_rsa .\`\) and access it inside the Dockerfile via the \`/run/secrets/\` path.
Journey Context:
A developer tries to use BuildKit secrets to pull from a private git repo during build: \`RUN --mount=type=secret,id=ssh git clone ...\`. The git clone fails with a permission denied error. They verify the SSH key works perfectly on their host machine. They realize they added the \`RUN --mount\` instruction in the Dockerfile but forgot to actually pass the secret from the host to the \`docker build\` command. The mount point was empty. They append \`--secret id=ssh,src=$HOME/.ssh/id\_rsa\` to their \`docker build\` command and set \`GIT\_SSH\_COMMAND="ssh -i /run/secrets/ssh"\` in the \`RUN\` instruction. The build succeeds, securely authenticating without leaving the private key in the final image layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:15:57.890145+00:00— report_created — created