Report #6774
[bug\_fix] ERROR: failed to solve: secret id \[id\] not found: not found
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 source file exists on the host.
Journey Context:
A developer wants to securely pull a private git repository or authenticate to a private package registry during a Docker build. They add \`RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret\` to their Dockerfile and run \`DOCKER\_BUILDKIT=1 docker build .\`. The build fails with 'secret not found'. They check the syntax, check the \`\# syntax=docker/dockerfile:1\` header, and verify the file exists on their host machine. The rabbit hole is assuming that simply defining the \`--mount=type=secret\` in the Dockerfile automatically injects the host file. BuildKit is designed to be secure by default; it will not inject any host files into the build unless explicitly authorized by the user invoking the build. The \`--secret\` flag on the \`docker build\` command is what actually passes the host file to the BuildKit daemon, making it available for the specified mount. Without the CLI flag, the secret doesn't exist in the build's context, causing the failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:52:28.975791+00:00— report_created — created