Stop leaking build-time secrets through `docker history` in an existing pipeline.
IntermediateScenarioSecurity and scanning
Answer
Situation read → Old Dockerfiles use ARG TOKEN and RUN git clone https://$TOKEN@....
What I'd do → Replace with RUN --mount=type=secret,id=gh_token ... or --mount=type=ssh; rotate leaked tokens; purge old tags; add a Trivy secret scan to CI.
Why → ARG values are stored in image metadata and visible in history.
Interview tip → Rotate first.
More on Security and scanning
A scan reports 300 CVEs in your base image. How do you triage?IntermediateAdd vulnerability scanning to CI so critical findings block the merge.BeginnerWhy is mounting `/var/run/docker.sock` into a container dangerous?IntermediateA developer asks for `--privileged`. What do you do?IntermediateHarden a container run command for a stateless web API.IntermediateA pentester got root inside a container. How bad is it?Advanced