Last updated: April 29, 2026
Why this module. Every container starts from a base image with hundreds of packages, most of which the application doesn’t use, all of which could have CVEs. Scanning is mandatory; scanning well is the differentiator.
Where to scan
- Build time — fail PRs that introduce new critical CVEs. Trivy / Grype in CI.
- Registry — re-scan on schedule (CVEs are discovered after publish). ECR/GHCR/ACR have native scanning.
- Runtime — Falco / Sysdig / Aqua observe what runs.
Tool comparison
- Trivy — open source, fast, broad coverage, Aqua-backed. Default choice.
- Grype — Anchore’s; same use cases.
- Docker Scout — integrated; easy onboarding.
- Snyk Container — paid; better remediation suggestions.
- JFrog Xray — enterprise; tied to Artifactory.
The CI integration pattern
# GitHub Actions example
- uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.build.outputs.image }}
severity: CRITICAL,HIGH
exit-code: 1
ignore-unfixed: true
ignore-unfixed: true is the unsung hero — only fail on CVEs that have a fix available. Otherwise you fail PRs for vulnerabilities nobody can fix.
Making scans actionable
- Distinguish fixable from non-fixable CVEs. Engineers can act on fixable; non-fixable need risk acceptance.
- Use distroless or chainguard base images — minimal surface. Often takes a 200-CVE alpine image to a 0-CVE distroless.
- Generate SBOM alongside scan. SBOM travels with image; lets you query “what images used log4j 2.14?” instantly.
- Suppress noise per-image with
.trivyignore; document why.
The registry-rescan pattern
Image was clean at build; new CVE published 3 weeks later affecting that image. Without rescan, you don’t know. Configure registry to rescan daily; alert when a previously-clean image becomes vulnerable.
What “vulnerable” doesn’t always mean
A CVE in a library you don’t actually call is still a CVE on the report — but lower-priority. Tools like Snyk and Endor Labs do reachability analysis: yes there’s a vulnerable function, but is your app calling it? This kills 60-80% of false-positive noise.
Defender’s checklist
- Trivy / Grype in every CI pipeline; fail on fixable CRITICAL/HIGH.
- Distroless or chainguard base images for production.
- SBOM generation + storage (CycloneDX or SPDX).
- Daily registry rescans; alerts on regressions.
- Monthly review: top recurring CVEs across image fleet.
- Reachability analysis at scale once vuln backlog is contained.
Module Quiz · 6 questions
Pass with 80%+ to mark this module complete. Unlimited retries. Each question shows an explanation.
Custom team training + practitioner advisory
Beyond the free academy — we run private workshops, vCISO advisory, and red-team exercises tailored to your stack. For Indian SMBs scaling past their first hire.