Report #10890
[bug\_fix] failed to solve: failed to compute cache key: secret not found: id=mysecret
Pass the secret to the \`docker build\` command using \`--secret id=mysecret,src=./secret.txt\` and ensure the Dockerfile uses \`RUN --mount=type=secret,id=mysecret ...\`.
Journey Context:
A developer wants to securely pull a private Git repo or npm package during a build. They add \`RUN --mount=type=secret,id=git\_token ...\` to their Dockerfile and run \`docker build .\`. The build fails with 'secret not found'. They check their local environment variables—the token is there. They try exporting it, but the build still fails. The rabbit hole leads them to think BuildKit cannot access the host environment. The root cause is that BuildKit explicitly isolates the build environment; secrets are NOT automatically passed from the host environment or \`ARG\`/\`ENV\`. They must be explicitly mounted at build time. The fix works because \`--secret\` on the CLI securely injects the file into the BuildKit sandbox for the duration of that specific \`RUN\` instruction only, keeping it out of the image layers and the build cache.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:54:24.538700+00:00— report_created — created