Report #63632
[bug\_fix] RUN --mount=type=secret fails with 'unsupported mount type: secret' or the secret is missing inside the RUN step.
Ensure BuildKit is explicitly enabled \(DOCKER\_BUILDKIT=1\) if using an older Docker version, and pass the secret to the build command using 'docker build --secret id=mysecret,src=mysecret.txt'.
Journey Context:
A developer needs to clone a private Git repository during a Docker build. They try 'ARG GIT\_TOKEN' and 'RUN git clone https://$GIT\[email protected]/repo.git'. It works, but security flags the image because the token is permanently baked into the image history. They switch to BuildKit's 'RUN --mount=type=secret,id=git\_token'. The build fails with 'unsupported mount type: secret'. They realize their default Docker daemon is using the legacy builder. They set 'DOCKER\_BUILDKIT=1' and add '--secret id=git\_token,src=$HOME/.git-token' to the build command. The fix works because BuildKit securely mounts the secret file into the container's temporary filesystem only for the duration of that specific RUN step, completely invisible to the final image layers and history.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:17:39.687854+00:00— report_created — created