Report #5692
[bug\_fix] undefined secret during docker build when using RUN --mount=type=secret,id=.
Pass the secret explicitly to the build command using the --secret flag \(e.g., docker build --secret id=,src= .\).
Journey Context:
A developer wants to securely pull a private npm package during a build without leaving credentials in the image layers. They add the BuildKit --mount=type=secret syntax to the Dockerfile. The build immediately fails with 'undefined secret mysecret'. They think the mount syntax is wrong and fiddle with the target path and environment variables. Eventually, they realize that BuildKit intentionally does not automatically inject secrets from the host environment or files just because they are referenced in the Dockerfile. The 'id' in the Dockerfile merely declares a requirement; the actual secret payload must be explicitly provided by the build client via the --secret flag during the docker build invocation. Adding the flag resolves the mount.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:53:05.536176+00:00— report_created — created