Report #1132
[bug\_fix] RUN --mount=type=secret fails with "could not parse secrets" or secret not available inside RUN
Pass secrets at build time with \`--secret id=mysecret,src=./file\` or \`--secret id=mysecret,env=ENV\_VAR\`, and reference them inside the Dockerfile with \`RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret\`. Do not commit secret files into the build context; BuildKit will refuse to use them if the file is also matched by .dockerignore. The \`required\` option defaults to true, so a missing --secret causes the build to fail. The root cause is that BuildKit mounts secrets as tmpfs under /run/secrets only for the duration of the RUN command; they are not persisted to layers and must be explicitly declared on both the CLI and the Dockerfile line.
Journey Context:
You need to pip install from a private index during build. You add \`RUN --mount=type=secret,id=pipconf pip install -r requirements.txt\` expecting \`/run/secrets/pipconf\` to contain your pip.ini. The build fails: "could not parse secrets: \[pipconf\] not found". You added the file to the repo, which violates the secret model and triggers .dockerignore exclusion. You remove the file from git, add it to .dockerignore, and instead run \`docker build --secret id=pipconf,src=$HOME/.config/pip/pip.conf .\`. The build succeeds, the secret is mounted only for that RUN layer, and \`docker history\` shows no trace of the credentials because they were never written to a layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T17:58:13.813151+00:00— report_created — created