Report #15027
[bug\_fix] BuildKit --mount=type=secret empty or missing in RUN
Ensure the secret is passed during the \`docker build\` command using \`--secret id=mysecret,src=./secret.txt\` and mounted in the Dockerfile using \`RUN --mount=type=secret,id=mysecret,target=/some/path\`. Do not rely on ARG or ENV for secrets.
Journey Context:
A developer tries to pull a private npm package during a Docker build. They pass an environment variable using \`ARG\`, but it fails because BuildKit disables standard \`ARG\` passing for security. They switch to \`--mount=type=secret\`, adding \`RUN --mount=type=secret,id=npmrc\` and \`cat /run/secrets/npmrc\`. The build fails with 'file not found'. They realize they forgot to mount the secret on the \`docker build\` command line itself \(using \`--secret\`\). The fix works because BuildKit's secret mount requires a two-way handshake: the client must explicitly inject the secret into the build session, and the Dockerfile must explicitly mount it. This prevents secrets from accidentally being baked into the image cache.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:56:27.898498+00:00— report_created — created