Image Vulnerability Scanning (docker scout, Trivy, Grype)
Scan images for CVEs in CI with Scout, Trivy, or Grype and gate on severity.
In plain words
Scan before merge, re-scan the release digest and gate critical/fixable findings under an explicit exception process.
Think of it like…
A scanner is a recalled-parts database: ownership, version and whether that part is installed determine the action, but the notice does not prove how an engine is assembled.
Where you’ve seen it
In practice, trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef is the concrete move for this job: scan images for CVEs in CI with Scout, Trivy, or Grype and gate on severity. The release is not accepted until save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build confirms the result.
Words you’ll hear
- Trivy
- The implementation control in
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeeffor scan images for CVEs in CI with Scout, Trivy, or Grype and gate on severity. - Scout
- The result to observe with
save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build, rather than infer from a successful command alone. - CVE Gate
- The production boundary exposed when failing on every Low finding until teams disable scanning, or scanning
app:latestin CI and deploying a different digest later.
Visual diagram
Theory & deep dive
Trivy control path
The concrete mechanism is trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef. The observable result is save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build; if those disagree, inspect the runtime evidence before changing unrelated settings.
Scan images for CVEs in CI with Scout, Trivy, or Grype and gate on severity. Keep Trivy, Scout and CVE Gate in the same deployment record so the intent and the observed state cannot drift apart.
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef
save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build, not with command success alone.CVE Gate failure boundary
Different scanners can report different counts because of CPE/advisory matching, source-package attribution and unsupported distros. A Critical in an unused Python wheel is not automatically worse than an exposed library with known exploitation, while an old digest may be cleaner only because it is stale. The narrow failure to design for is failing on every Low finding until teams disable scanning, or scanning app:latest in CI and deploying a different digest later.
Accept this compromise explicitly: Policy gating is predictable; risk acceptance plus exploitability review is necessary for unpatched transitive vulnerabilities. The controlled check-save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build-also identifies the point where a different design is safer.
Exercise this failure safely: failing on every Low finding until teams disable scanning, or scanning app:latest in CI and deploying a different digest later.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: Different scanners can report different counts because of CPE/advisory matching, source-package attribution and unsupported distros. A Critical in an unused Python wheel is not automatically worse than an exposed library with known exploitation, while an old digest may be cleaner only because it is stale.
- Intent
- Trivy
When to use it & trade-offs
What it is
Trivy, Grype and Docker Scout compare package inventories and distro advisories with SBOM-like metadata from image layers. Severity and exploitability must be combined with package reachability, fix availability and policy; a scanner’s database age affects results.
Why it matters: Different scanners can report different counts because of CPE/advisory matching, source-package attribution and unsupported distros. A Critical in an unused Python wheel is not automatically worse than an exposed library with known exploitation, while an old digest may be cleaner only because it is stale.
When to reach for it
- The fit is strongest for this job: scan images for CVEs in CI with Scout, Trivy, or Grype and gate on severity. Pair it with
save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base buildin the runbook. - Production Trivy changes should make Scout observable through
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef, rather than trusting the runtime default. - Keep a rollback example for the case where failing on every Low finding until teams disable scanning, or scanning
app:latestin CI and deploying a different digest later.
When to avoid or be careful
- Do not accept command success while the system can still fail by failing on every Low finding until teams disable scanning, or scanning
app:latestin CI and deploying a different digest later. - Avoid erasing CVE Gate protection merely to dodge this cost: “Policy gating is predictable; risk acceptance plus exploitability review is necessary for unpatched transitive vulnerabilities”.
- Do not replace the evidence path-
save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build-with a screenshot or a mutable tag.
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef: practical choices
Strengths: Trivy, Grype and Docker Scout compare package inventories and distro advisories with SBOM-like metadata from image layers. Severity and exploitability must be combined with package reachability, fix availability and policy; a scanner’s database age affects results.
Watch out: Policy gating is predictable; risk acceptance plus exploitability review is necessary for unpatched transitive vulnerabilities.
Strengths: It can begin with trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef and fewer surrounding controls.
Watch out: It silently accepts failing on every Low finding until teams disable scanning, or scanning app:latest in CI and deploying a different digest later, which makes the result hard to reproduce after promotion.
Strengths: Different scanners can report different counts because of CPE/advisory matching, source-package attribution and unsupported distros. A Critical in an unused Python wheel is not automatically worse than an exposed library with known exploitation, while an old digest may be cleaner only because it is stale.
Watch out: The platform adds an ownership and debugging layer; retain save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build as the direct check.
Interview signals & numbers to know
When this topic comes up
- trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef
- save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build
- Failure signature: failing on every Low finding until teams disable scanning, or scanning app:latest in CI and deploying a different digest later
- Trade-off: Policy gating is predictable; risk acceptance plus exploitability review is necessary for unpatched transitive vulnerabilities.
Benchmarks & rules of thumb
- 2 scan moments
- pull request and exact release digest
- CRITICAL,HIGH
- example deployment gate
- 0 unfixed
- may mean an unresolved risk rather than permission to ignore
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeefas proof and skippingsave JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build. - Failing on every Low finding until teams disable scanning, or scanning
app:latestin CI and deploying a different digest later - Optimizing Trivy without accepting that policy gating is predictable; risk acceptance plus exploitability review is necessary for unpatched transitive vulnerabilities.
Likely interviewer follow-ups
- Why does
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeefaddress Trivy here rather than through application code? - How would you distinguish healthy Scout from the failure “failing on every Low finding until teams disable scanning, or scanning
app:latestin CI and deploying a different digest later” usingsave JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build? - When would this trade-off-“Policy gating is predictable; risk acceptance plus exploitability review is necessary for unpatched transitive vulnerabilities”-justify a different CVE Gate design?
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed ghcr.io/acme/api@sha256:deadbeef-and one proof-save JSON for the exact digest, confirm vulnerability DB timestamp and compare OS/library findings after the fixed base build. Then name the boundary: failing on every Low finding until teams disable scanning, or scanning app:latest in CI and deploying a different digest later.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Image Vulnerability Scanning (docker scout, Trivy, Grype) with generative AI interview Q&A and hands-on practice.