Skip to content

Trivy

115 commands

Aqua’s all-in-one scanner for vulnerabilities, misconfigurations, secrets and licenses in container images, filesystems, repositories, IaC and Kubernetes.

  • vulnerability scanning
  • containers
  • IaC
  • SBOM

Install Trivy

sudo apt install trivy

Basic Usage2

trivy --help

Displays the main help menu and available subcommands for Trivy.

trivy version

Checks the installed version of Trivy to ensure it is up to date.

Basic Image Scan2

trivy image [IMAGE_NAME]

Performs a standard vulnerability scan on a container image using the default database.

Link
trivy image [IMAGE_ID]

Scans a local container image referenced by its specific Image ID.

Link

Filesystem Scan2

trivy fs [DIRECTORY]

Scans the current directory and subdirectories for dependencies and lock files.

Link
trivy fs <path>

Modifies scanning target bounds extracting explicit Docker contexts analyzing completely raw explicit standard system source files mapped entirely cleanly across any Linux environment.

Link

Repository Scan1

trivy repo [REPO_URL]

Clones and scans a remote Git repository for vulnerabilities in one step.

Link

Configuration Scan1

trivy config [DIRECTORY]

Scans Infrastructure as Code (IaC) files like Terraform and Kubernetes manifests for misconfigurations.

Link

Severity Filtering1

trivy image --severity [LEVELS] [IMAGE]

Filters scan results to show only vulnerabilities matching the specified severity levels.

Link

Vulnerability Filtering1

trivy image --ignore-unfixed [IMAGE]

Hides vulnerabilities that do not yet have a patch or fix available.

Link

Vulnerability Types2

trivy image --vuln-type [TYPES] [IMAGE]

Restricts the scan to Operating System package vulnerabilities only.

Link
trivy image --vuln-type library [IMAGE]

Restricts the scan to application dependency vulnerabilities (e.g., npm, pip, gomod).

Link

Secrets Scanning1

trivy fs --scanners secret [DIRECTORY]

Scans the filesystem specifically for hardcoded secrets, keys, and passwords.

Link

License Scanning1

trivy fs --scanners license [DIRECTORY]

Scans the filesystem to classify and detect software licenses in dependencies.

Link

Combined Scanners1

trivy image --scanners vuln,secret,misconfig [IMAGE]

Runs vulnerability, secret detection, and misconfiguration scans simultaneously on an image.

Link

Output Formatting3

trivy image --format json --output [FILE] [IMAGE]

Outputs the scan results in raw JSON format to a specified file.

Link
trivy image --format table [IMAGE]

Displays scan results in a human-readable table format in the terminal (default).

Link
trivy image --format sarif --output [FILE] [IMAGE]

Generates a SARIF report suitable for integration with GitHub Security code scanning.

Link

SBOM Generation2

trivy image --format cyclonedx --output [FILE] [IMAGE]

Generates a CycloneDX Software Bill of Materials (SBOM) from a container image.

Link
trivy image --format spdx-json --output [FILE] [IMAGE]

Generates an SPDX JSON Software Bill of Materials (SBOM) from a container image.

Link

SBOM Scanning1

trivy sbom [FILE]

Scans a pre-generated SBOM file for vulnerabilities without re-analyzing the original image.

Link

CI/CD Integration2

trivy image --exit-code 1 --severity CRITICAL [IMAGE]

Forces the process to exit with code 1 if CRITICAL vulnerabilities are found, breaking the build.

Link
trivy image --exit-code 0 --severity HIGH [IMAGE]

Logs HIGH severity vulnerabilities but exits with code 0 to allow the build pipeline to continue.

Link

Ignore Files1

trivy image --ignorefile [FILE] [IMAGE]

Scans an image while excluding specific vulnerabilities defined in a .trivyignore file.

Link

Database Management2

trivy image --download-db-only

Downloads the vulnerability database to the cache without performing a scan.

Link
trivy image --reset

Resets the vulnerability database and clears the cache to fix corruption or force an update.

Link

Offline Scanning1

trivy image --offline-scan [IMAGE]

Scans using the currently cached database without attempting to reach the internet.

Link

Skipping Resources3

trivy image --skip-db-update [IMAGE]

Skips the vulnerability database update step to speed up repeated scans.

Link
trivy fs --skip-dirs [DIRS] [PATH]

Excludes specified directories from the filesystem scan to reduce noise and time.

Link
trivy fs --skip-files [FILES] [PATH]

Excludes specific files from being parsed during a filesystem scan.

Link

Archive Scanning1

trivy image --input [FILE]

Scans a container image exported as a tar archive (e.g., from docker save).

Link

Private Registry1

trivy image [REGISTRY_IMAGE]

Scans an image from a private registry using environment variables for authentication.

Link

Kubernetes Scanning4

trivy k8s cluster --report summary

Scans the entire connected Kubernetes cluster and outputs a summary report.

Link
trivy k8s --namespace [NS] all

Scans all resources (pods, deployments, services) within a specific Kubernetes namespace.

Link
trivy k8s --include-namespaces [NS] cluster

Restricts the cluster scan to only the specified namespaces.

Link
trivy k8s resource [KIND]/[NAME]

Scans a specific Kubernetes resource type and name found in the active cluster.

Link

AWS Cloud Scanning3

trivy aws --region [REGION] --service [SERVICE]

Scans AWS S3 bucket configurations in the specified region for security issues.

Link
trivy aws --service ec2

Scans AWS EC2 instances and security groups for misconfigurations.

Link
trivy aws --arn [ARN]

Scans a specific AWS resource identified by its Amazon Resource Name (ARN).

Link

VM Scanning1

trivy vm [IMAGE_FILE]

Scans a virtual machine disk image (QCOW2, VMDK, etc.) for OS vulnerabilities.

Link

Detailed Output1

trivy image --list-all-pkgs [IMAGE]

Outputs all detected packages in the image, regardless of whether they have vulnerabilities.

Link

Template Reporting1

trivy image --format template --template "@[PATH]" [IMAGE]

Generates a report using a custom Go template (e.g., HTML) for visualization.

Link

Policy Check1

trivy config --policy [DIR] [TARGET]

Applies custom Rego policies located in a directory to the configuration scan.

Link

Policy Namespaces1

trivy config --policy-namespaces [NS] [TARGET]

Restricts custom policy evaluation to specific Rego namespaces.

Link

Module Scanning1

trivy rootfs [DIR]

Scans an unpacked root filesystem directly, often used for host OS scanning.

Link

Cache Management2

trivy clean --scan-cache

Clears the artifact scan cache to force re-analysis of previously scanned images.

Link
trivy clean --all

Removes all caches, including the vulnerability database and scan results.

Link

Server Mode1

trivy server --listen [ADDRESS]

Starts Trivy in server mode to handle scan requests from remote clients.

Link

Client Mode1

trivy client --remote [URL] [IMAGE]

Sends a scan request to a remote Trivy server instead of using a local database.

Link

Client Mode Authentication1

trivy client --token [TOKEN] --remote [URL] [IMAGE]

Connects to a protected Trivy server using a token header for authentication.

Link

Containerized Scan1

docker run aquasec/trivy [COMMAND]

Runs Trivy itself inside a Docker container, mounting the host's Docker socket to scan sibling containers.

Link

History Filtering1

trivy image --history [IMAGE]

Analyzes the build history of the container image to associate vulnerabilities with specific layers.

Link

Compliance Scanning1

trivy k8s --compliance [STANDARD] --report summary

Scans the Kubernetes cluster against a specific compliance standard like NSA or CIS.

Link

Insecure Registry1

trivy image --insecure [IMAGE]

Allows scanning images from a registry that uses self-signed SSL certificates or HTTP.

Link

Timeout Control1

trivy image --timeout [DURATION] [IMAGE]

Sets a custom timeout duration for the scan operation to prevent hanging in pipelines.

Link

Java DB1

trivy image --download-java-db-only

Downloads only the Java index database used for scanning JAR/WAR files.

Link

Secrets Config1

trivy fs --secret-config [FILE] [DIR]

Uses a custom configuration file to define regex patterns for secret detection.

Link

Output Suppression1

trivy image --quiet [IMAGE]

Suppresses the progress bar and log messages, outputting only the final report.

Link

Helm Chart Scanning1

trivy config [CHART_DIR]

Scans Helm chart templates for security misconfigurations and best practice violations.

Link

Cloud Formation Scanning1

trivy config [TEMPLATE_FILE]

Scans AWS CloudFormation templates for infrastructure security risks.

Link

Vulnerability Database URL1

trivy image --db-repository [URL] [IMAGE]

Specifies a custom OCI registry URL to download the vulnerability database from.

Link

Rekor Attestation1

trivy image --rekor-url [URL] [IMAGE]

Verifies the image attestation against a specified Rekor transparency log server.

Link

Vulnerability Prioritization1

trivy image --vex [FILE] [IMAGE]

Uses a VEX (Vulnerability Exploitability Exchange) file to filter out non-exploitable vulnerabilities.

Link

Module Scan - Go1

trivy fs --scanners vuln [GO_PROJECT]

Scans a Go project directory, parsing go.mod and go.sum for dependency vulnerabilities.

Link

Module Scan - Python1

trivy fs [PYTHON_PROJECT]

Scans a Python project, identifying vulnerabilities in requirements.txt, Pipfile.lock, or poetry.lock.

Link

Custom Cache Dir1

trivy image --cache-dir [DIR] [IMAGE]

Specifies a custom directory for storing the vulnerability database and artifact cache.

Link

Docker Archive Scan1

trivy image --input [TAR] --format json

Scans a tarballed Docker image and outputs JSON, useful for air-gapped pipeline stages.

Link

Interactive Mode Debug1

trivy image --debug [IMAGE]

Runs the scan with verbose debug logging to troubleshoot detection or network issues.

Link

Remote Repo Branch1

trivy repo --branch [BRANCH] [URL]

Scans a specific branch of a remote Git repository instead of the default branch.

Link

Remote Repo Commit1

trivy repo --commit [HASH] [URL]

Scans a specific commit hash within a remote Git repository.

Link

Kubernetes Context1

trivy k8s --context [CTX] cluster

Specifies which kubeconfig context to use when scanning a Kubernetes cluster.

Link

Dependency Tree1

trivy image --dependency-tree [IMAGE]

Displays the hierarchy of dependencies to show which root package brought in a vulnerability.

Link

Parallel Scanning1

trivy k8s --parallel [N] cluster

Sets the number of concurrent scan jobs when scanning Kubernetes resources to improve speed.

Link

Misconfiguration IDs1

trivy config --include-non-failures [DIR]

Reports all configuration checks, including those that passed, for audit purposes.

Link

Force Update1

trivy image --refresh [IMAGE]

Forces a refresh of the cached layer information for the image before scanning.

Link

Specific Check IDs1

trivy config --check-namespaces [NS] [DIR]

Runs only specific Rego checks from a given namespace against the configuration.

Link

Ignore Status1

trivy image --ignore-status [STATUS] [IMAGE]

Ignores vulnerabilities that have a specific status in the vulnerability database.

Link

Platform selection1

trivy image --platform [PLATFORM] [IMAGE]

Scans the image architecture variant specifically for ARM64 or other platforms.

Link

Plugin Installation1

trivy plugin install [URL]

Installs a Trivy plugin from a Git repository to extend functionality.

Link

Plugin Usage1

trivy [PLUGIN_NAME] [ARGS]

Executes an installed plugin command, such as the kubectl plugin for pod scanning.

Link

Attestation Scan1

trivy image --sbom-sources [SOURCE] [IMAGE]

Retrieves the SBOM from a signing transparency log (Rekor) rather than generating it.

Link

Redis Cache Backend1

trivy image --cache-backend redis://[HOST]

Uses a Redis instance as the cache backend instead of the local filesystem for distributed scanning.

Link

Advanced Filtering1

trivy image --severity HIGH,CRITICAL --ignore-unfixed --vuln-type os [IMAGE]

Combines multiple filters to find only fixable, high-risk OS vulnerabilities.

Link

Azure Cloud1

trivy azure --service [SERVICE]

Scans Azure Blob Storage configurations for public access risks (experimental/preview).

Link

GCP Cloud1

trivy google --project [PROJECT]

Scans Google Cloud Platform resources within a specific project for misconfigurations (experimental).

Link

Cloud Snapshot Scan1

trivy vm --scanners vuln [SNAPSHOT_ID]

Scans an AWS EBS snapshot directly by mounting it securely (requires proper IAM permissions).

Link

Output Template - HTML1

trivy image --format template --template "@contrib/html.tpl" --output report.html [IMAGE]

Generates a visual HTML report using the contrib template for stakeholder presentation.

Link

Output Template - JUnit1

trivy image --format template --template "@contrib/junit.tpl" --output junit.xml [IMAGE]

Generates a JUnit XML report for parsing by CI systems like Jenkins or GitLab.

Link

Helm Value Overrides1

trivy config --helm-values [FILE] [CHART]

Scans a Helm chart while applying a specific values.yaml file to render the templates accurately.

Link

Terraform Variables1

trivy config --tf-vars [FILE] [DIR]

Scans Terraform code while applying variables from a tfvars file to resolve dynamic blocks.

Link

GitLab CI Workflow1

trivy image --no-progress --format template --template "@contrib/gitlab.tpl" -o gl-container-scanning-report.json [IMAGE]

Generates a JSON report formatted specifically for GitLab's Container Scanning dashboard integration.

Link

Diff Scans1

trivy image --diff-id [ID1] --diff-id [ID2]

Compares two scans by Image ID to identify new vulnerabilities introduced between versions.

Link

Registry Token Auth1

trivy image --registry-token [TOKEN] [IMAGE]

Uses a bearer token directly for registry authentication instead of username/password.

Link

Custom Rego Data1

trivy config --data [DIR] [TARGET]

Passes external data files (JSON/YAML) to Rego policies for context-aware configuration scanning.

Link

Removed Packages1

trivy image --removed-pkgs [IMAGE]

Detects vulnerabilities in packages that were removed but might still leave artifacts or traces.

Link

Scan Distroless1

trivy image [DISTROLESS_IMAGE]

Scans Google Distroless images by analyzing the /var/lib/dpkg/status file or binary headers.

Link

Air-Gapped Workflow1

tar -cf db.tar db/ && trivy image --cache-dir . --offline-scan [IMAGE]

Simulates an air-gapped workflow where the DB is manually transported and used for offline scanning.

Link

Compliance Report - CIS1

trivy k8s --compliance k8s-cis-1.23 --report summary

Checks the cluster specifically against the CIS Kubernetes Benchmark v1.23.

Link

Suppress Exit on Error1

trivy image --exit-on-eol [INT] [IMAGE]

Exits with a specific error code if the OS version of the image has reached End of Life (EOL).

Link

Config File Params1

trivy --config [CONFIG_YAML] image [IMAGE]

Runs a scan using global parameters (cache, timeout, format) defined in a YAML configuration file.

Link

Full Pipeline Simulation1

trivy image --exit-code 1 --severity CRITICAL --no-progress --format sarif -o report.sarif [IMAGE]

A complete pipeline command: checks criticals, fails build on hit, stays silent, and saves SARIF artifacts.

Link

Image Triage1

trivy image <image>

Processes explicit multi-layered localized dependencies systematically executing heavily updated internal algorithms checking actively vulnerable libraries physically inside the OCI map.

Link

Security Checks1

trivy image --security-checks vuln,secret,config <image>

Broadens aggressively limited explicit arrays completely indexing deeply integrated logic actively unmasking hardcoded passwords locally bridging systemic Dockerfile misconfigurations.

Link

High Priority1

trivy image --severity HIGH,CRITICAL <image>

Replaces standard tracking output inherently silencing unmitigated non-patchable trivial bugs strictly inherently exposing completely unmitigated massively destructive unpatched flaws.

Link

AWS Bridging1

trivy aws --region <region>

Alters API integration natively hooking directly entirely across localized authenticated extremely explicit inherent AWS architecture environments exposing highly misconfigured resources globally.

Link

Kubernetes Scan1

trivy k8s --report summary <type>

Navigates entirely across inherently deeply massive internal native K8S clusters completely profiling absolutely explicit running pods mapping heavily integrated inherent system failures.

Link

SBOM Output1

trivy image --format spdx-json -o <file> <image>

Aggregates massive deep software package matrices perfectly encoding entirely locally natively to strict absolute SPDX specifications fundamentally tracking explicitly supply chain integrations.

Link

Ignore Logic1

trivy image --ignore-unfixed <image>

Suppresses inherently incredibly aggressive matching loops actively disabling heavily documented explicit bugs cleanly validating natively exactly instances where patches formally physically exist.

Link

Caching Logic1

trivy image --clear-cache

Obiterates deeply compiled immensely massive local historic configuration states manually fundamentally overriding natively deeply corrupted extraction database arrays.

Link

Remote Server1

trivy client --remote <url> <image>

Bridges unauthenticated explicitly limited inherent container operations effectively entirely deferring complex parsing actively targeting centralized massive extremely high-power analytical infrastructures.

Link

Config Auditing1

trivy config <path>

Unlinks CVE dependencies completely tracking entirely explicit misconfigurations deeply hardcoded internally strictly inside Terraform, CloudFormation, or Dockerfile manifest bounds.

Link

Repository Traversal1

trivy repository <url>

Fundamentally clones extremely massive completely remote public organizational git mappings dynamically executing exhaustive pipeline scanning locally devoid entirely of containers.

Link

Air-Gapped Scans1

trivy image --offline-scan

Aggressively restricts all outgoing network loops systematically enforcing internal offline validations perfectly resolving issues entirely isolating tracking algorithms dynamically.

Link

Plugin Integrations1

trivy plugin install <plugin>

Modifies internal functionality extending systemic analysis bridges strictly loading dynamic external plugins expanding Trivy's innate explicit runtime reporting modules natively.

Link

Advanced Exporting1

trivy image -o <file.html> --template <path>

Bridges fundamental GO templating logic explicitly tracking incredibly massive native CVE responses and perfectly generating absolutely clean heavily styled HTML reports.

Link