Trivy — All-in-One Security Scanner for Containers & Code
Trivy is an open-source, comprehensive security scanner that finds vulnerabilities, misconfigurations, secrets, and SBOM issues in containers, Kubernetes, code repos, and clouds.
What it is
Trivy is an open-source security scanner by Aqua Security that detects vulnerabilities in OS packages and language dependencies, misconfigurations in Terraform and Dockerfiles, leaked secrets like API keys, and SBOM issues -- all from a single binary with zero configuration. It scans Docker images, Git repositories, Kubernetes clusters, and local filesystems.
Trivy targets DevSecOps engineers, platform teams, and developers who need security scanning integrated into CI/CD pipelines without managing multiple specialized tools.
How it saves time or tokens
Trivy consolidates what used to require four or five separate tools (vulnerability scanner, secret detector, IaC linter, SBOM generator, Kubernetes auditor) into one binary. A single trivy image nginx:latest command replaces a chain of Grype, detect-secrets, checkov, and kube-bench commands. The scanner runs offline-capable with a local vulnerability database, so CI pipelines avoid network round-trips to external APIs.
How to use
- Install Trivy:
# macOS
brew install trivy
# Debian/Ubuntu
sudo apt install trivy
- Scan a Docker image for vulnerabilities:
trivy image nginx:latest
- Scan a Git repository for secrets and misconfigurations:
trivy repo https://github.com/your-org/your-repo
- Audit a running Kubernetes cluster:
trivy k8s --report=summary cluster
Example
# Scan a project filesystem with all scanners enabled
trivy fs --scanners vuln,misconfig,secret /path/to/project
# Output as JSON for CI/CD integration
trivy image --format json --output results.json myapp:v2.1
# Fail the build if critical vulnerabilities are found
trivy image --exit-code 1 --severity CRITICAL myapp:v2.1
# Generate an SBOM in CycloneDX format
trivy image --format cyclonedx --output sbom.json myapp:v2.1
Related on TokRepo
- Security tools directory -- Other security scanning and auditing tools
- DevOps tools -- CI/CD and infrastructure automation solutions
Common pitfalls
- The first scan downloads a vulnerability database (~30MB) which can timeout in air-gapped environments; pre-download with
trivy image --download-db-onlybefore going offline - Scanning large monorepo filesystems with all scanners enabled can be slow; use
--scannersflag to limit to specific scan types - The
--exit-code 1flag only triggers on findings matching the specified severity; omitting--severitymeans any finding fails the build
Frequently Asked Questions
Trivy scans container images, local filesystems, Git repositories, Kubernetes clusters, and cloud infrastructure (AWS, GCP, Azure). Each target type supports the full range of scanners: vulnerabilities, misconfigurations, secrets, and SBOM generation.
Grype focuses solely on vulnerability scanning for container images. Snyk is a commercial platform covering vulnerabilities and IaC. Trivy covers vulnerabilities, misconfigurations, secrets, and SBOM in a single open-source binary, making it broader in scope than Grype and free unlike Snyk.
Yes. Trivy provides JSON, SARIF, and table output formats. The --exit-code flag lets you fail builds on findings. Official GitHub Actions, GitLab CI templates, and Jenkins plugins are available. The scanner runs as a single binary with no daemon or server dependency.
Trivy can work offline after the initial vulnerability database download. Run 'trivy image --download-db-only' to cache the database, then use '--skip-db-update' for subsequent scans. This is useful for air-gapped environments.
Trivy detects API keys, passwords, tokens, private keys, and other credentials embedded in source code, Dockerfiles, and container image layers. It uses pattern matching and entropy analysis to minimize false positives.
Citations (3)
- Trivy GitHub— Trivy is a comprehensive security scanner by Aqua Security
- Trivy Documentation— Supports scanning containers, filesystems, repos, and Kubernetes
- Trivy SBOM Docs— SBOM generation in CycloneDX and SPDX formats
Related on TokRepo
Discussion
Related Assets
Moodle — Open-Source Learning Management System
The most widely used open-source learning platform, providing course management, assessments, and collaboration tools for educators and organizations worldwide.
Sylius — Headless E-Commerce Framework on Symfony
An open-source headless e-commerce platform built on Symfony and API Platform, designed for developers who need a customizable and API-first commerce solution.
Akaunting — Free Self-Hosted Accounting Software
A free, open-source online accounting application built on Laravel for small businesses and freelancers to manage invoices, expenses, and financial reports.