Trivy scan job sometimes takes 2 seconds and passes, sometimes 4 minutes and fails, for the same image
AdvancedTroubleshootingContainer image and IaC scanning
Answer
Likely causes → A stale scan result cache keyed by image ID is reused, or the DB update failed silently with --skip-db-update and an old DB.
Diagnose →
trivy image --debug myapp:1.4 2>&1 | grep -E "DB|cache"
trivy --version # shows DB version and UpdatedAt
Fix → Clear or scope the cache (trivy clean --scan-cache), refresh the DB at job start, and print DB metadata in logs.
Prevent → Fail the job if the DB is older than a threshold, so results are reproducible and explainable.
More on Container image and IaC scanning
Trivy fails the build on 14 HIGH/CRITICAL CVEs in the base image, all with "Fixed Version" emptyBeginner`FATAL ... failed to download vulnerability DB: ... TOOMANYREQUESTS: retry-after` from Trivy in CIIntermediateTrivy in an air-gapped runner fails with `failed to download vulnerability DB` even though you copied `db.tar.gz`AdvancedTrivy and Grype report different CVE counts for the same imageIntermediate`.trivyignore` entries are ignored and the build still fails on the same CVEBeginnerTrivy reports a critical CVE in a Go binary built from your own code, in package `stdlib`Intermediate