Report #35187
[bug\_fix] Private package installation fails with authentication errors during \`docker build\`, despite using \`RUN --mount=type=secret\` in the Dockerfile
Ensure the \`--secret\` flag is passed to the \`docker build\` command \(e.g., \`--secret id=npmrc,src=.npmrc\`\) and that \`DOCKER\_BUILDKIT=1\` is enabled if using an older Docker version.
Journey Context:
A developer wants to install private npm packages without baking the \`.npmrc\` token into the image. They add \`RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm install\` to their Dockerfile. The build fails with 401 Unauthorized. They spend hours checking file permissions on the host, the token's validity, and BuildKit syntax. They finally realize that while the Dockerfile requests the mount, they forgot to inject the secret from the host during the build command. The build command must include \`docker build --secret id=npmrc,src=$HOME/.npmrc .\` for the mount to actually receive the file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:31:53.681713+00:00— report_created — created