Secure Docker Images with Trivy
Build a deliberately weak image, scan it with Trivy, and rebuild it until the gate for fixable HIGH and CRITICAL findings passes: current base, non-root user, patched packages, no pip in the runtime image.
Path 02 · learning path
From Dockerfile to registry: scanning images, producing SBOMs, reducing the attack surface and keeping the results actionable.
Each part names what it needs. Nothing has to be installed before part 1.
The path
Each part states what it assumes from the previous one, so you can also jump in where your setup already is.
How Trivy finds OS and application vulnerabilities, secrets and misconfigurations in container images, how to make the results actionable, and how to wire it into CI without slowing builds down.
Build the same Go service as a single-stage image and as a multi-stage image on a distroless base, then compare size, package count, scanner findings and the user it runs as.
Practise
Build a deliberately weak image, scan it with Trivy, and rebuild it until the gate for fixable HIGH and CRITICAL findings passes: current base, non-root user, patched packages, no pip in the runtime image.
Produce CycloneDX and SPDX bills of materials for a container image without a Docker socket, scan the SBOM with Grype, gate on fixable findings only, and see why the SBOM is worth keeping after the release.
Toolchain
After the last part
One path picks up where this one stops. It is a suggestion, not a requirement.
Inventory, scan, sign and verify one real image, from dependencies to the digest a cluster may run.