Report #49988
[tooling] Build-time secrets passed via ARG or ENV are leaked in image layers and history
Mount secrets at build time using --secret id=mysecret,src=env.txt and access them at /run/secrets/mysecret without leaving traces
Journey Context:
Using ARG for secrets embeds them in the image history inspectable via docker history. The --secret flag mounts a temporary file into the build context that is never committed to a layer; it exists only for the RUN command that mounts it via --mount=type=secret. This ensures secrets never persist in the final image, solving the layer leakage problem definitively.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:23:24.451839+00:00— report_created — created