trivy for Container Image Scanning

trivy scans images for CVEs.

Basic usage

Trivy covers three surfaces with three commands. trivy image scans a container image and reports CVEs by severity with fixed versions and library context; trivy fs scans a filesystem or git repo for vulnerabilities; trivy config scans IaC manifests for misconfigurations.

CI integration

CI integration runs trivy at every layer of the build. Pre-build scans catch issues before image build; post-build scans give the comprehensive view including base-image vulnerabilities; severity gates fail the build on critical or high CVEs with documented escape valves for known-not-applicable issues.

Ignoring known issues

Ignoring known issues needs structure. .trivyignore lists CVEs to skip for false positives or accepted risk; VEX attestations are the structured way to mark CVEs as not-applicable and are better than .trivyignore for compliance; periodic review catches ignores that no longer apply.

Registry integration

Trivy integrates with registries to scan on push. Trivy server mode is a long-running scanner; pull-on-push triggers scans on every image push with results visible in the registry UI; cached scans reuse the trivy database locally so the same image layer doesn’t re-pay the scan cost.

Trivy vs alternatives

The alternatives have different trade-offs. Snyk is commercial with richer remediation suggestions and developer-tool integrations; Grype (Anchore) has a similar feature set with a different vulnerability database, and some teams run both for coverage; Trivy’s advantages are being open source, broad scanner support, and fast updates.