November 28, 2026 Free pentesting academy for Web2 & Web3
Container and Kubernetes Security Scanning with Trivy: Images, IaC, Secrets and SBOMs
Share

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.

Aqua Trivy logo
Trivy, an all-in-one open-source security scanner. Source: aquasecurity/trivy.

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*" .
Trivy targets and scanners overview
What Trivy can scan and what it looks for. Source: aquasecurity/trivy.

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-unfixed and 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.

Was this tutorial useful?
Share

The pentestwiki.org editorial team: practising penetration testers, red teamers and smart contract auditors who write, test and peer-review every tutorial before publication.

Need a professional assessment? Our team performs authorized penetration tests and smart contract audits.
See services

Get new tutorials in your inbox

One email when a new guide, cheat sheet or Web3 security write-up is published. No spam, unsubscribe in one click.

By subscribing you accept our Privacy Policy. Unsubscribe anytime.