Report #49454
[bug\_fix] ERROR: failed to solve: secret not found: id=mysecret
Pass the secret to the \`docker build\` command using the \`--secret\` flag \(e.g., \`docker build --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 repository during a Docker build without leaving credentials in the image layers. They add \`RUN --mount=type=secret,id=gitcreds git clone ...\` to their Dockerfile. When they run \`docker build .\`, it fails with 'secret not found'. They double-check the syntax, which is correct. They then realize that BuildKit does not automatically mount host files or environment variables as build secrets; it requires explicit consent and mapping from the CLI. They run the build again, this time appending \`--secret id=gitcreds,src=$HOME/.git-credentials\`, successfully mounting the host file into the isolated build step without persisting it in the final image.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:29:26.967607+00:00— report_created — created