Skip to main content

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.

โœ“ Docker & OCI image scanning โœ“ Terraform & Kubernetes IaC โœ“ Secret detection โœ“ SARIF output for GitHub Security tab โœ“ 100% open-source

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 tableHuman review in terminal
JSON--format jsonProgrammatic processing, dashboards
SARIF--format sarifGitHub Security tab integration
CycloneDX--format cyclonedxSBOM generation, compliance

Trivy vs Alternatives

Tool IaC Secrets SBOM License
Trivyโœ“โœ“โœ“Apache 2.0
Snykโœ“โœ“โœ“Commercial
Grypeโœ—โœ—โœ“ (Syft)Apache 2.0
Docker Scoutโœ—โœ—โœ“Commercial
Share this tool: X / Twitter LinkedIn
โœ“ 60,000+ developers use DevPlaybook โ˜…โ˜…โ˜…โ˜…โ˜… 4.8 / 5 on Gumroad โœ“ MIT licensed ยท Instant download โœ“ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Related Articles

Apr 4, 2026 ยท 12 ๅˆ†้˜

curl ๆทฑๅบฆไฝฟ็”จๆ‰‹ๅ†Š๏ผšAPI ๆธฌ่ฉฆๅพžๅ…ฅ้–€ๅˆฐ้€ฒ้šŽ

curl ๆ˜ฏๆฏไฝ้–‹็™ผ่€…ๅฟ…ๅ‚™็š„ CLI ๅทฅๅ…ทใ€‚ๆœฌๆ–‡ๆถต่“‹ GET/POST/PUT/DELETE ่ซ‹ๆฑ‚ใ€่ช่ญ‰ใ€header ่จญๅฎšใ€ๆช”ๆกˆไธŠๅ‚ณใ€้™ค้ŒฏๆŠ€ๅทง๏ผŒไปฅๅŠ REST API ๆธฌ่ฉฆ็š„ๅฎŒๆ•ดๅฏฆๆˆฐ็ฏ„ไพ‹ใ€‚

Apr 2, 2026 ยท 8 min read

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.

Apr 2, 2026 ยท 10 min read

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.

Apr 2, 2026 ยท 13 min read

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.

Apr 2, 2026 ยท 11 min read

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.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • โšก AI Code Review, Doc Generator & SQL Builder
  • โšก All premium templates & early access
  • โšก Member discounts on Gumroad products
Start Free Trial โ†’

$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.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro โ€” $79 โ†’

MIT licensed ยท Instant download ยท No subscription

See what's included โ†’ Browse all deals โ†’