Trivy by Aqua Security is a single scanner for container images, filesystems, Git repositories, infrastructure-as-code and Kubernetes clusters. It detects vulnerabilities, misconfigurations, exposed secrets and license issues, and it generates SBOMs. This guide shows how to use it across the software lifecycle and how to gate a CI/CD pipeline on real risk.

Installation
# Script install
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin
# Homebrew
brew install trivy
trivy --version
Scanning container images
# Full image scan
trivy image myorg/app:1.4.2
# Only actionable issues: fixable, high/critical
trivy image --severity HIGH,CRITICAL --ignore-unfixed myorg/app:1.4.2
# Scan an image tarball built in CI before it is pushed
trivy image --input app.tar
--ignore-unfixed hides vulnerabilities with no available patch so the team focuses on things it can actually act on.
Filesystem, repositories and secrets
# Scan source code dependencies and secrets together
trivy fs --scanners vuln,secret,misconfig .
# Scan a remote Git repository
trivy repo https://github.com/myorg/service
The secret scanner catches API keys and tokens accidentally committed. Add it to a pre-commit hook so secrets are caught before they ever reach the remote.
Infrastructure as code
# Terraform, CloudFormation, Dockerfile, Kubernetes manifests
trivy config .
# Just the Dockerfile best-practices and misconfig checks
trivy config --file-patterns "dockerfile:Dockerfile*" .

Kubernetes
# Cluster-wide security report
trivy k8s --report summary cluster
# A single namespace
trivy k8s --report all --namespace production
SBOMs
# Generate a CycloneDX SBOM
trivy image --format cyclonedx -o sbom.cdx.json myorg/app:1.4.2
# Later, scan that SBOM for newly disclosed vulnerabilities
trivy sbom sbom.cdx.json
Keeping SBOMs means you can re-check shipped artifacts against newly disclosed CVEs without rebuilding them.
Gating CI/CD without breaking builds
# Fail the build only on fixable high/critical issues
trivy image --exit-code 1 --severity HIGH,CRITICAL --ignore-unfixed myorg/app:1.4.2
Document accepted risks in a .trivyignore file with a reason and a review date:
# .trivyignore
# Accepted until 2026-09-01 — not reachable in our usage, tracked in TICKET-123
CVE-2025-12345
Key takeaways
- One tool scans images, filesystems, repos, IaC and Kubernetes.
- Use
--ignore-unfixedand limit severity so teams act on real, fixable risk. - Add the secret scanner to pre-commit to stop leaks early.
- Generate SBOMs so you can re-check shipped artifacts against future CVEs.
Frequently asked questions
What can Trivy scan?
Container images, filesystems, Git repositories, virtual machine images, Kubernetes clusters and infrastructure-as-code files, detecting vulnerabilities, misconfigurations, exposed secrets and software licenses.
How do I stop Trivy from failing builds on unfixable CVEs?
Use –ignore-unfixed, limit –severity to HIGH,CRITICAL, and document accepted risks in a .trivyignore file with justification and review dates.
