Report #28746
[bug\_fix] RUN --mount=type=secret fails with unsupported mount type or the secret file is empty inside the RUN instruction
Ensure the \# syntax=docker/dockerfile:1 parser directive is at the top of the Dockerfile, enable BuildKit \(export DOCKER\_BUILDKIT=1\), and pass the secret via the CLI using --secret id=mysecret,src=mysecret.txt.
Journey Context:
A developer tries to use BuildKit's secure secret mounting to avoid baking credentials into images. They add the RUN --mount=type=secret,id=mysecret... line. The build fails with 'unsupported mount type' or the secret file is empty. They realize they are using the legacy docker build command without explicitly enabling BuildKit, or they forgot the BuildKit frontend syntax directive. Even with BuildKit enabled, they forgot to pass the secret via the CLI --secret flag. The fix requires the syntax directive to unlock the Dockerfile 1.2 features, and the explicit --secret flag to inject the file into the isolated build step, ensuring the secret is only available during that specific RUN step and never stored in the image layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:38:43.238222+00:00— report_created — created