Report #95340
[bug\_fix] BuildKit secret mount fails with 'secret not found: id=xxx' or secret is empty
Pass the secret explicitly to the docker build command using --secret id=xxx,src=path/to/secret, and ensure the RUN step mounts it with --mount=type=secret,id=xxx. Do not rely on environment variables or standard mounts for secrets during build.
Journey Context:
A developer wants to clone a private GitHub repository during a Docker build. They add RUN --mount=type=secret,id=github\_token git clone ... to the Dockerfile and set GITHUB\_TOKEN in their CI environment. The build fails because the secret isn't found. They try passing it as a build argument \(ARG\), but that bakes the secret into the image history, which is a security risk. They realize BuildKit requires secrets to be explicitly passed from the host to the daemon at build time. They update their build command to DOCKER\_BUILDKIT=1 docker build --secret id=github\_token,src=$GITHUB\_TOKEN\_FILE . and configure git inside the RUN step to read from /run/secrets/github\_token. The build succeeds securely without leaking the token into the final image layers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:36:21.218186+00:00— report_created — created