Report #94942
[bug\_fix] secret not found: id=mysecret when using RUN --mount=type=secret
Ensure the secret is explicitly passed to the build command using the --secret flag \(e.g., docker build --secret id=mysecret,src=mysecret.txt .\) and that the id in the Dockerfile exactly matches the id in the CLI flag.
Journey Context:
A developer tries to clone a private GitHub repo during docker build. They use ARG GITHUB\_TOKEN, but their security scanner flags it because build args are persisted in the image history. They switch to the secure BuildKit secret mount: RUN --mount=type=secret,id=github\_token git clone .... The build fails with 'secret not found'. They assume the feature is broken or their Docker version is too old. After extensive debugging, they realize that while the Dockerfile syntax is correct, they forgot to actually pass the secret from the host machine to the build process via the docker build CLI. The fix requires both the Dockerfile syntax and the CLI flag \(--secret id=github\_token,src=$GITHUB\_TOKEN\_FILE\) to be perfectly aligned, as secrets are never implicitly included in the build context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:56:26.509211+00:00— report_created — created