Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
trivy image nginx:1.27
trivy image --severity HIGH,CRITICAL --ignore-unfixed registry.example.com/shop/api:1.4.2
trivy image --exit-code 1 --severity CRITICAL --ignore-unfixed registry.example.com/shop/api:1.4.2
trivy fs --scanners vuln,secret,misconfig .The first run downloads the vulnerability database. Install Trivy from the official repository (see the full guide).
Step by step
- Read the result table:
trivy image --severity HIGH,CRITICAL shop/api:1.4.2
shop/api:1.4.2 (debian 12.8)
Total: 3 (HIGH: 2, CRITICAL: 1)
┌──────────┬────────────────┬──────────┬────────┬───────────────────┬───────────────────┐
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │
├──────────┼────────────────┼──────────┼────────┼───────────────────┼───────────────────┤
│ libssl3 │ CVE-2026-12345 │ CRITICAL │ fixed │ 3.0.15-1~deb12u1 │ 3.0.17-1~deb12u1 │
└──────────┴────────────────┴──────────┴────────┴───────────────────┴───────────────────┘The two most useful columns: Status (fixed = an update exists) and Fixed Version.
- Fix in this order:
| Finding | Usual fix |
|---|---|
OS package, fixed | Rebuild on a newer base image tag (docker build --pull). |
| App library (pip, npm, Maven, Go) | Update the dependency in your lock file. |
| Many findings from tools you do not need | Smaller base: slim, distroless, multi-stage. |
affected / will_not_fix (no fix yet) | Check if the code path is used; document; watch for a fix. |
- Gate the pipeline — fail only on what you can act on, so the team does not ignore the gate:
trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed --no-progress registry.example.com/shop/api:1.4.2Exit code 1 stops the CI job. Start with CRITICAL only, then add HIGH.
- Accept a risk in a documented way — a
.trivyignorefile in the repo, with a reason and a date:
# CVE in a parser we do not call; review again 2027-01-15 (ticket SEC-142)
CVE-2026-12345- More than images:
trivy fs --scanners secret .
trivy config ./terraform
trivy image --format cyclonedx -o sbom.cdx.json registry.example.com/shop/api:1.4.2
trivy k8s --report summarySecrets in code, misconfigured Terraform/Kubernetes files, an SBOM for the image, and the whole cluster.
- Scan again regularly — new CVEs are found every day in images that did not change. Rescan the images you run (daily in CI, or in the registry: Harbor scans on push and on a schedule).
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Hundreds of findings, team gives up | Big base image, all severities shown. | Slim base; gate on CRITICAL,HIGH with --ignore-unfixed; fix in batches. |
| Rebuild did not reduce findings | The old base image was cached. | docker build --pull --no-cache; use a newer base tag. |
CI fails with TOOMANYREQUESTS / DB download errors | Rate limits on the DB download. | Cache the DB between jobs, or use a mirror (--db-repository). |
| Same CVE found again and again with no fix | Upstream has no fix yet. | --ignore-unfixed in the gate; a dated .trivyignore entry. |
| A secret is reported in the image | A key or .env was copied in. | Remove it, rotate the secret, add .dockerignore. |
| A pinned GitHub Action or Trivy version changed behaviour | Security tools are supply-chain targets too. | Install from the official repo; pin actions by commit SHA; read release notes. |
Go further
- Command pages: trivy, docker.
- Next how-tos: Write a small and safe Dockerfile, Push an image to a private registry, Create a CI pipeline in GitHub Actions, Create an SBOM, Sign an image with Cosign, Find vulnerable dependencies with Grype.
- Full guides: Trivy, Grype, Syft, Cosign, Harbor.
- At work: Trivy in daily use, A secure pipeline. Learn it: Docker — Scan.
- Practise: Lab: build a CI pipeline that tests, scans and gates the merge.
1What does --ignore-unfixed do, and why use it in a CI gate?
It hides findings with no fixed version yet, so the gate fails only on things the team can fix now.
2Your image did not change for months. Why scan it again?
New CVEs are published every day; old images get new findings.