Internative Logo

What Is Trivy? The Open-Source Scanner for Containers and IaC

What Is Trivy? The Open-Source Scanner for Containers and IaC

A container image is rarely just your code. It carries a base operating system, system libraries, a language runtime and hundreds of third-party packages, and any of them can have a known vulnerability. Infrastructure code has the same problem in a different form: one open security group in a Terraform file or one privileged Kubernetes pod can undo a lot of careful work. Trivy is an open-source scanner that checks all of this in one pass, quickly enough to run on every commit, so security problems are found in the pipeline instead of in production.

This article explains what Trivy is, how it works, where it fits in a delivery pipeline, where it does not, and how it compares with the alternatives.

What is Trivy?

Trivy is an open-source security scanner maintained by Aqua Security and released under the Apache 2.0 licence. It finds known vulnerabilities (CVEs), infrastructure-as-code misconfigurations, exposed secrets and software licence issues in container images, file systems, code repositories, virtual machine images and Kubernetes clusters. It ships as a single binary and needs no server or database of its own.

It started as a personal project. Teppei Fukuda wrote Trivy in his spare time and tagged the first release, v0.0.1, on GitHub on 7 May 2019. Aqua Security offered him a full-time role to develop it, and later in 2019 the project moved to Aqua's GitHub organisation while staying open source. In July 2021 Aqua acquired tfsec, a Terraform scanner, and folded its checks into Trivy, which turned a container scanner into a broader tool for infrastructure code as well.

The name is pronounced "tri" as in trigger and "vy" as in envy.

How Trivy works

Targets and scanners. Trivy separates what it scans from what it looks for. Targets include container images, a local file system or root file system, a remote Git repository, virtual machine images, a Kubernetes cluster and an existing SBOM. Scanners include vulnerabilities, misconfigurations, secrets and licences. You combine them on the command line: scan this image for vulnerabilities and secrets, or this folder for misconfigurations.

Inventory first, then matching. For vulnerabilities, Trivy first builds an inventory of what is installed: operating system packages such as those in Alpine, Debian or Red Hat images, and language dependencies read from lock files for ecosystems such as Node.js, Python and Java. It then matches that inventory against its vulnerability database and reports each finding with its severity and, where one exists, the fixed version.

A downloaded database. The vulnerability database is not built on your machine. Trivy downloads it and keeps it up to date, and for networks without internet access the database can be self-hosted, so scans also work in air-gapped environments.

Checks for infrastructure code. Misconfiguration scanning reads Terraform, CloudFormation, Dockerfiles, Kubernetes manifests and Helm charts and evaluates them against built-in checks, for example a container running as root or a storage bucket open to the public. Teams can add their own checks.

Exit codes for pipelines. Trivy can return a non-zero exit code when it finds issues above a chosen severity. That single setting is what turns a report into a gate: the build fails when an image contains a critical vulnerability that has a fix available.

Key features

  • One tool, several scanners: vulnerabilities, misconfigurations, secrets and licences from the same binary.
  • SBOM support: Trivy generates software bills of materials in CycloneDX and SPDX formats and can scan an existing SBOM instead of the artefact itself.
  • Wide target coverage: images, file systems, repositories, VM images and live Kubernetes clusters.
  • Pipeline integrations: an official GitHub Action, and plain CLI use in GitLab CI/CD, Jenkins and other CI systems.
  • Trivy Operator for Kubernetes, which scans workloads continuously inside the cluster.
  • Editor and registry integrations, including a VS Code extension. The Harbor container registry uses Trivy as its default scanner.

Where Trivy is used

  • CI/CD pipelines, as a gate that blocks images with fixable critical vulnerabilities before they are pushed or deployed.
  • Container registries, to rescan stored images when new CVEs are published.
  • Infrastructure-as-code reviews, scanning Terraform and Helm changes in pull requests.
  • Kubernetes clusters, through the Trivy Operator, to find vulnerable or misconfigured workloads that are already running.
  • Supply-chain and compliance work, where customers or regulators ask for an SBOM of what you ship.

When to choose Trivy, and when not to

Choose Trivy when:

  • You build and ship Docker images and want vulnerability scanning in the pipeline without buying a platform first.
  • You want one tool for images, infrastructure code and secrets, rather than three separate scanners.
  • You need SBOMs in standard formats.
  • Scans must run offline or inside a closed network.

Look elsewhere when:

  • You need analysis of the code your team wrote, such as injection flaws or unsafe data flows. That is static application security testing (SAST), and tools such as SonarQube are built for it. Trivy looks at dependencies, configuration and secrets, not at your application logic.
  • You need a managed service with dashboards, policy management, prioritisation and developer workflows across many teams. A commercial platform such as Snyk, or Aqua's own commercial products, adds that layer.
  • You need dynamic testing of a running application. Scanners like Trivy do not attack an endpoint; that is the job of penetration testing and DAST tools.

A lesson from 2026. In March 2026 Trivy itself was the target of a supply-chain attack. Using credentials obtained in an earlier intrusion, attackers published a malicious Trivy v0.69.4 release on 19 March and force-pushed most version tags of the trivy-action and setup-trivy GitHub Actions to malicious commits. Aqua removed the artefacts, published safe versions and asked affected users to rotate every secret their pipelines could reach. The practical takeaway applies to any tool in a pipeline: pin GitHub Actions to a full commit SHA instead of a version tag, and limit which secrets a scanning job can see.

Trivy and its alternatives

ToolTypeFocusBest fit
TrivyOpen source (Apache 2.0)Vulnerabilities, IaC, secrets, licences, SBOMOne scanner for images and infrastructure code
Grype + SyftOpen source (Apache 2.0)Vulnerabilities, with Syft for SBOMsTeams that want separate SBOM and scan steps
SnykCommercial platformDependencies, code, containers, IaCManaged platform across many teams
SonarQubeFree and commercial editionsCode quality and SASTAnalysing first-party source code

Grype, sponsored by Anchore, is the closest open-source alternative. It works with Syft: Syft builds the SBOM and Grype matches it against vulnerability data. Trivy does both in one binary and adds misconfiguration and secret scanning. Many teams run Trivy for containers and infrastructure next to a SAST tool for their own code, because the two cover different risks. Scanning is one part of a wider delivery practice, which we described in DevOps and CI/CD: continuous improvement in software development.

How we use Trivy at Internative

We use Trivy to automate security scanning of containers and infrastructure code. It is fast and easy to plug into a pipeline, so security checks run early in delivery and do not slow releases down.

If you want security checks built into your build and release process, our DevOps services and infrastructure security teams can help you decide where scanning belongs and what should block a release.

Frequently asked questions

What does Trivy detect?

Trivy detects known vulnerabilities in operating system packages and language dependencies, misconfigurations in infrastructure-as-code files such as Terraform, Dockerfiles and Kubernetes manifests, secrets such as API keys and passwords committed by mistake, and software licences that may conflict with your policy. It can also produce an SBOM of everything it finds.

Is Trivy a SAST tool?

No. Static application security testing analyses the source code you wrote for flaws such as injection or unsafe data handling. Trivy scans what surrounds that code: dependencies, container layers, configuration and secrets. SonarQube is a SAST and code quality tool, so Trivy and SonarQube are usually used together rather than as substitutes.

What is the difference between Grype and Trivy?

Both are open-source vulnerability scanners for images and file systems. Grype, from Anchore, focuses on vulnerability matching and relies on its companion tool Syft to generate SBOMs. Trivy covers vulnerabilities, SBOM generation, misconfigurations and secrets in one binary.

Is Trivy open source and free?

Yes. Trivy is open source under the Apache 2.0 licence and free to use, including in commercial pipelines. Aqua Security maintains it and sells separate commercial products built on top of it.

How is Trivy pronounced?

According to the project's own FAQ, "tri" is pronounced as in trigger and "vy" as in envy.

Related services

Where this topic becomes an engagement.

Keep reading

The articles that follow this one.