Skip to main content
Cloud DevOps Solutions
Get a quote Talk to an engineer

DevSecOps and secrets

Trivy Vulnerability Scanning Done Properly: Rollout, Tuning and Honest Limits

Trivy is an open source scanner that finds known vulnerabilities, misconfigurations, exposed secrets and licence issues in container images, repositories, filesystems and Kubernetes clusters, and can generate SBOMs. We integrate it into CI and the cluster, set severity gates, and tune results so developers fix what matters.

Key takeaways

  • Trivy finds known issues in packages and some misconfigurations. It does not find unknown bugs in your own code or prove an image is safe.
  • Gate on severity plus fix availability for new findings, and report the rest, or teams will bypass the scanner.
  • Most image findings come from the base image. Standardising and refreshing bases removes more noise than any ignore file.
  • Scan at build time and rescan deployed images on a schedule, because the vulnerability database changes after you ship.
  • Every exception needs an owner, a reason and an expiry date.

What teams use Trivy for

Container image scanning in CI

Each build is scanned before push, with results visible in the pull request and a gate on serious, fixable findings.

Repository and dependency scanning

Lock files and manifests are checked for vulnerable libraries across languages, catching issues before the image build.

Infrastructure and manifest checks

Terraform, Dockerfiles, Helm output and Kubernetes manifests are scanned for risky configuration such as privileged containers or open security groups.

Cluster scanning with the Trivy Operator

A Kubernetes operator scans running workloads and stores reports as custom resources, so you see what is deployed rather than what was built.

SBOM generation

CycloneDX or SPDX bills of materials are produced per release and stored, so you can answer which services use a newly disclosed library within minutes.

What Trivy is and why teams adopt it

Trivy is an open source security scanner from Aqua Security. It ships as a single binary with no server to run, which is a large part of why it spreads: an engineer can add it to a pipeline in minutes. It reads container images, repositories and clusters, compares what it finds against vulnerability databases, and also checks configuration files and looks for exposed secrets.

That ease is also the trap. A scanner that is added quickly and left at default settings produces hundreds of findings, developers learn to ignore them, and the programme quietly fails. Our Trivy consulting is mostly about the work around the tool: policy, base images, exception handling and where results appear. We cover the container-specific pipeline details in Trivy image scanning in CI/CD.

How we run Trivy in production

In the pipeline

A pull request scan for a repository and a build scan for the image cover different risks. The repository scan catches vulnerable dependencies and misconfigured manifests early; the image scan catches what the base image and OS packages add. A typical GitHub Actions step looks like this:

- name: Scan image
  uses: aquasecurity/trivy-action@master
  with:
    image-ref: ${{ env.IMAGE }}
    severity: HIGH,CRITICAL
    ignore-unfixed: true
    exit-code: "1"
    format: sarif
    output: trivy.sarif

We pin the action to a release or commit rather than a moving branch, cache the vulnerability database so scans stay fast, and upload SARIF so findings appear in the security tab. The same options work from the command line in GitLab CI or Jenkins. See the sibling page on GitHub Actions for the wider pipeline design.

In the cluster

The Trivy Operator runs inside Kubernetes and scans workloads as they run, producing vulnerability, configuration and exposed secret reports as custom resources. This matters because the image in production may have been built months ago. We export the reports to Prometheus metrics or your dashboards and route them by namespace owner. The operator uses cluster resources for its scan jobs, so we set concurrency limits and schedules to avoid straining small nodes.

Tuning findings so they are worth reading

Tuning is where most of the value is.

  • Fix the base image first. A small set of approved, regularly rebuilt base images typically accounts for most findings. Refreshing them weekly through automated pull requests removes whole classes of noise.
  • Use fix availability. Ignoring unfixed findings in the gate (while still reporting them) prevents blocking on problems nobody can resolve.
  • Gate on new, not old. Existing debt is tracked and burned down separately. A pull request should fail because of what it introduces.
  • Prefer VEX or targeted ignores. An ignore with a reason, owner and expiry is documentation. A blanket severity ignore is a blind spot.
  • Separate dev and runtime dependencies. A vulnerable test library does not carry the same risk as one in the runtime path.

Our container security hardening and container image scanning with Trivy and ECR pages describe the registry side.

Cost, capacity and speed

The question we hear most is whether scanning will slow the pipeline. Done well, it should add well under the time of a typical test stage, because the database is cached and only changed artefacts are scanned.

Trivy itself is free, but the pipeline cost is real. Downloading the database on every job adds time and can hit rate limits on the default registry, so we mirror or cache it. Large monorepos benefit from scanning only changed images and lock files. Operator reports in a big cluster create many custom resources, which adds load on the API server, so retention and scan frequency are tuned.

Day-2 operations

  • Database freshness. Scheduled rescans of deployed images matter as much as build scans. An image clean on Monday can carry a critical finding on Friday with no change.
  • Version management. Scanner and action versions are updated deliberately, because a new version can change results and break a previously passing build.
  • SBOM retention. Bills of materials are stored per release, ideally in a tool such as Dependency-Track, so a new disclosure can be matched to services quickly.
  • Ownership. Findings route to the team that owns the service. A central security inbox does not scale.

Honest limits

Trivy matches known identifiers. It does not find logic flaws, unknown vulnerabilities or insecure code in your own application; that is the job of static analysis such as SonarQube and review. Its misconfiguration checks overlap with, but are not as deep as, a dedicated IaC scanner like Checkov. It reports presence, not reachability, so many findings are not exploitable in your context. And a clean scan says nothing about runtime behaviour, which is where Falco fits.

Rolling out without blocking developers

We run the scan in report-only mode for a couple of weeks, publish the top ten causes of findings, and fix those at the base image level before any gate fails a build. Only then do we turn on a blocking check, limited to new high and critical findings with a fix. Teams keep a documented way to request an exception, and the platform team reviews them weekly, so nobody waits long for an answer.

When to choose something else

If you want developer-facing fix suggestions, support contracts and a hosted dashboard, a commercial tool may serve you better. If you need agentless coverage across whole cloud accounts, look at a cloud security platform. For many startups, Trivy plus good base images is a strong and inexpensive start.

Working with us

We start with a baseline scan, agree a gate in report-only mode, then enforce on new findings once the noise is down. For ongoing ownership, our managed DevOps service can run the scanning programme with you. To discuss your setup, get in touch.

Official documentation: trivy.dev

How we work with Trivy

  1. 01

    Baseline what you run

    We scan registries and running workloads to see the real starting position and the biggest sources of findings, usually a handful of base images.

  2. 02

    Agree the policy

    Together we decide which severities fail a build, whether unfixed findings count, which paths are scanned and who approves exceptions.

  3. 03

    Add scanning to pull requests and builds

    A fast scan runs with a cached database, outputs SARIF or comments on the pull request, and fails only on the agreed class of finding.

  4. 04

    Fix at the source

    We standardise base images, add automated dependency updates and reduce image contents, which removes most findings structurally.

  5. 05

    Scan what is running

    Scheduled rescans or the Trivy Operator catch newly disclosed issues in deployed workloads and route them to the owning team.

  6. 06

    Govern exceptions and hand over

    Ignore rules and VEX statements are reviewed on a schedule, and your team receives a runbook for database updates and policy changes.

Trivy compared with the alternatives

We recommend the tool that fits your team, not the one we know best. Here is when each option makes sense.

OptionChoose it when
TrivyTrivy is an open source scanner that finds known vulnerabilities, misconfigurations, exposed secrets and licence issues in container images, repositories, filesystems and Kubernetes clusters, and can generate SBOMs.
Grype with SyftChoose it if you want a focused vulnerability scanner paired with a dedicated SBOM generator, and do not need Trivy's misconfiguration and secret scanning in one binary.
SnykChoose it if you want a commercial platform with developer IDE integration, fix pull requests and support, and have budget for it. Compare findings quality on your own stack first.
Registry scanning (ECR, ACR, Artifact Registry)Choose it as a complement for continuous monitoring of stored images. It is convenient but runs after the push and offers less control than a CI gate.
Wiz or a CNAPPChoose a cloud security platform if you need agentless scanning across cloud accounts, attack path analysis and a team to act on it. Trivy is a tool, not a platform.

Tools we use alongside Trivy

GitHub ActionsGitLab CITrivy OperatorSARIFGitHub code scanningSyftGrypeCycloneDXSPDXDependency-TrackRenovateCosignAmazon ECRKyverno

Frequently asked questions

What does Trivy scan?
Trivy scans container images, filesystems, Git repositories and Kubernetes clusters. It looks for known vulnerabilities in operating system packages and language dependencies, misconfigurations in files such as Dockerfiles, Terraform and Kubernetes manifests, hard-coded secrets and licence issues, and it can output SBOMs. It matches against known data, so it cannot find undisclosed flaws.
Should Trivy fail the build?
Only for findings that are serious and actionable. We usually fail on high and critical vulnerabilities that have a fix available and that are introduced by the change, and we report the rest. Failing every build on old, unfixable findings trains developers to skip the scan, which is worse than a softer gate.
Why does Trivy report so many vulnerabilities in my image?
Usually because of a large base image carrying many packages you never use. Moving to a slimmer or distroless base, rebuilding regularly and removing build tools from the final stage typically cuts findings sharply. Many remaining items are not reachable in your application, which is why triage and exceptions matter.
How do we ignore a vulnerability safely?
Record it in an ignore file or a VEX statement with the CVE, a reason such as not reachable or no fix available, an owner and an expiry date. Expiry forces a re-check instead of permanent silence. Avoid blanket ignores by severity or package, which hide new problems along with the old ones.
Is Trivy enough for container security?
No. It covers known vulnerabilities and some configuration issues at scan time. You also need hardened images, least-privilege runtime settings, admission policy, secrets management and runtime detection for behaviour, for example with Falco. Scanning is a useful layer, not a complete programme.
Trivy or Grype: which should we use?
Both are capable open source scanners and produce broadly similar results, with differences at the margins in data sources and matching. Trivy covers more scan types in one tool, while Grype is narrower and pairs with Syft. We usually run a comparison on your own images and pick the one your team prefers.

Talk to an engineer about Trivy

Book a free 30-minute call. We review your current setup and tell you honestly whether and how we can help.

Written by Saddique Khan, DevOps / SRE / Cloud Consultant Engineer. Last updated 2026-10-09.