Report #82789
[bug\_fix] ERROR: failed to solve: secret not found: id=npmrc
Pass the secret explicitly during the build command using the --secret flag, e.g., docker build --secret id=npmrc,src=./.npmrc .
Journey Context:
A developer tries to use BuildKit's secure secret mounting feature to install private npm packages using RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm install. The build fails immediately claiming the secret ID cannot be found. They check their local directory and the .npmrc file exists. They go down a rabbit hole checking file permissions and BuildKit versions. The realization hits that the Dockerfile syntax only declares a requirement for a secret mount; it does not automatically inject files from the build context for security reasons. BuildKit strictly requires the secret to be explicitly passed from the host machine via the docker build CLI arguments at build time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:33:16.484434+00:00— report_created — created