Trivy Container Scanner: Docker Image & IaC Security Scanning
Trivy is an open-source, all-in-one vulnerability and misconfiguration scanner from Aqua Security. It scans container images, filesystems, Git repositories, Kubernetes manifests, and Terraform โ making it the go-to tool for cloud-native security pipelines.
What is Trivy?
Trivy (Trivial Vulnerability scanner) detects CVEs in OS packages and language-specific dependencies, misconfigurations in IaC files, and exposed secrets in source code โ all with a single binary and no daemon required. It's widely adopted in Kubernetes environments and integrates natively with GitHub Actions, GitLab CI, and ArgoCD.
Installation
# Homebrew (macOS/Linux)
brew install aquasecurity/trivy/trivy
# Debian/Ubuntu
sudo apt-get install wget apt-transport-https gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee /etc/apt/sources.list.d/trivy.list
sudo apt-get update && sudo apt-get install trivy
# Docker
docker run --rm aquasec/trivy image nginx:latest Scan Docker Images
# Scan a public image
trivy image nginx:latest
# Scan your own image
trivy image myapp:1.0.0
# Only show CRITICAL and HIGH
trivy image --severity CRITICAL,HIGH myapp:1.0.0
# Skip unfixed vulnerabilities (less noise)
trivy image --ignore-unfixed myapp:1.0.0
# Output as JSON
trivy image --format json --output report.json myapp:1.0.0 Scan Filesystem & Git Repos
# Scan local filesystem (app dependencies + secrets)
trivy fs .
# Scan a git repository remotely
trivy repo https://github.com/myorg/myrepo
# Scan with secret detection enabled
trivy fs --scanners secret .
# Scan specific directory
trivy fs --scanners vuln,secret ./src/ Scan IaC โ Terraform & Kubernetes
# Scan Terraform files
trivy config ./terraform/
# Scan Kubernetes YAML manifests
trivy config ./k8s/
# Scan Helm chart
trivy config ./charts/myapp/
# Scan a single file
trivy config deployment.yaml IaC scanning catches issues like containers running as root, missing read-only root filesystems, privilege escalation enabled, hostPath volumes, and open ingress ports โ all before kubectl apply.
GitHub Actions Integration
name: Trivy Security Scan
on: [push, pull_request]
jobs:
trivy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t myapp:{{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'myapp:{{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
exit-code: '1'
- name: Upload SARIF to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif' Output Formats
| Format | Flag | Best For |
|---|---|---|
| Table | --format table | Human review in terminal |
| JSON | --format json | Programmatic processing, dashboards |
| SARIF | --format sarif | GitHub Security tab integration |
| CycloneDX | --format cyclonedx | SBOM generation, compliance |
Trivy vs Alternatives
| Tool | IaC | Secrets | SBOM | License |
|---|---|---|---|---|
| Trivy | โ | โ | โ | Apache 2.0 |
| Snyk | โ | โ | โ | Commercial |
| Grype | โ | โ | โ (Syft) | Apache 2.0 |
| Docker Scout | โ | โ | โ | Commercial |
Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad โAI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini โ organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad โDeveloper Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad โYou Might Also Need
JSON Formatter & Validator
Format, beautify, and validate JSON online. Paste your JSON to instantly pretty-print it with 2-space, 4-space, or tab indentation. Minify JSON too. Free, runs in your browser.
Open free tool โ
Regex Tester
Free regex tester. Test regular expressions against multiple strings with expected match/no-match assertions โ see instant pass/fail results. Built-in presets for email, URL, IPv4, and phone. Pro: unl
Open free tool โ
Base64 Encoder & Decoder
Free Base64 Encoder & Decoder. Convert text, images, and any file to Base64 and back. Supports URL-safe Base64, image data URIs, and file download from Base64. Runs 100% in your browser โ no data sent
Open free tool โ
More Free Tools
Related Articles
curl ๆทฑๅบฆไฝฟ็จๆๅ๏ผAPI ๆธฌ่ฉฆๅพๅ ฅ้ๅฐ้ฒ้
curl ๆฏๆฏไฝ้็ผ่ ๅฟ ๅ็ CLI ๅทฅๅ ทใๆฌๆๆถต่ GET/POST/PUT/DELETE ่ซๆฑใ่ช่ญใheader ่จญๅฎใๆชๆกไธๅณใ้ค้ฏๆๅทง๏ผไปฅๅ REST API ๆธฌ่ฉฆ็ๅฎๆดๅฏฆๆฐ็ฏไพใ
Best AI Code Review Tools 2026: CodeRabbit, Sourcery, DeepCode & Bito Compared
Compare top AI code review tools for 2026: CodeRabbit, Sourcery, DeepCode, and Bito. Features, pricing, GitHub/GitLab integration, and choosing the right tool for your team.
AI Code Review Tools 2026: GitHub Copilot, CodeRabbit, Qodo Merge Ranked
Compare AI code review tools for 2026: GitHub Copilot code review, CodeRabbit, Qodo Merge, Sourcery, and PR-Agent. Pricing, accuracy, and GitHub integration.
AI Coding Tools Comparison 2026: GitHub Copilot vs Cursor vs Windsurf vs Cline
Comprehensive comparison of the best AI coding tools in 2026: GitHub Copilot, Cursor, Windsurf, and Cline. Pricing, features, model support, and real-world benchmarks.
AI Pair Programming in 2026: GitHub Copilot vs Cursor vs Claude Code
Master AI pair programming in 2026. Compare GitHub Copilot, Cursor, and Claude Code for autocomplete, chat, and agentic workflows. Includes setup guides and productivity tips.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- โก AI Code Review, Doc Generator & SQL Builder
- โก All premium templates & early access
- โก Member discounts on Gumroad products
$9/mo after trial ยท Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products โ grab them all at once and save big.
MIT licensed ยท Instant download ยท No subscription
See what's included โ Browse all deals โ