How do you scan an image with Trivy and fail a CI build on serious findings?
BeginnerProductionImage Security & Hardening
Answer
trivy image --severity HIGH,CRITICAL --exit-code 1 --ignore-unfixed registry.example.com/app:1.4.2
--exit-code 1 fails the pipeline, --ignore-unfixed avoids blocking on CVEs with no patch. Scan the image you will deploy (by digest), not just the Dockerfile, and also run trivy config . for Dockerfile/IaC misconfigurations.
More on Image Security & Hardening
Why should containers not run as root, and how do you enforce it?BeginnerWhat is a distroless image and what are the trade-offs?BeginnerHow do you manage Trivy false positives and accepted risks?IntermediateWhich `docker run` flags make up a hardened runtime baseline?BeginnerWhat does `no-new-privileges` protect against?BeginnerHow should secrets be handled in container workloads?Beginner