Report #59752
[bug\_fix] ERROR: failed to solve: secret not found: not found
Pass the secret to the \`docker build\` command using the \`--secret id=,src=\` flag, in addition to defining the \`--mount=type=secret,id=\` in the Dockerfile.
Journey Context:
A developer wants to install a private Git repository via npm or pip during a Docker build. They add \`RUN --mount=type=secret,id=sshkeys,target=/root/.ssh/id\_rsa pip install git\+ssh://...\` to the Dockerfile and run \`docker build .\`. The build fails instantly with 'secret not found'. They check the local \`~/.ssh/id\_rsa\` file, verify permissions \(600\), and try mounting host volumes, which breaks isolation. The rabbit hole continues as they suspect BuildKit bugs. The root cause is that BuildKit is designed to prevent secrets from accidentally leaking into the build context or image layers; it will not automatically read host files. The fix works because the \`--secret\` CLI flag explicitly grants the BuildKit daemon temporary, secure access to the host file for the duration of that specific \`RUN\` instruction.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:47:08.358495+00:00— report_created — created