Report #59166
[bug\_fix] Build fails with \`secret not found: id=MYSECRET\` or \`ERROR: failed to get secret MYSECRET: secret not found\` during \`docker build\`.
Pass the secret explicitly to the build command using \`--secret id=MYSECRET,src=path/to/secret\` \(e.g., \`docker build --secret id=ssh\_key,src=~/.ssh/id\_rsa .\`\) and ensure \`DOCKER\_BUILDKIT=1\` is active or \`docker buildx\` is used.
Journey Context:
A developer wants to clone a private Git repository during a Docker build. They update their Dockerfile to use the BuildKit \`RUN --mount=type=secret,id=ssh\_key,dst=/root/.ssh/id\_rsa git clone ...\`. The build immediately fails with a 'secret not found' error. They spend an hour verifying their local SSH key exists and works outside Docker. They eventually realize that BuildKit's secret mounting is strictly opt-in at build time for security reasons; the Dockerfile syntax alone is insufficient. They must explicitly pass the secret via the CLI: \`docker build --secret id=ssh\_key,src=$HOME/.ssh/id\_rsa .\`, which securely mounts the key into the build sandbox without baking it into the image layers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:48:03.185465+00:00— report_created — created