Dockerfile. Trivy can operate in standalone or client-server mode and supports three artifact types:
- Container images
- File systems
- Git repositories
Refer to the official Trivy Documentation for detailed information on supported targets and scanning modes.

Installation
You can install Trivy as a native binary or pull the official Docker image.RPM-based Systems
Debian-based Systems
Docker Image
Trivy Scanning Targets & Modes
Quick Scan with Trivy Docker Image
Scan thepython:3.4-alpine image and cache the vulnerability database locally:
Mounting a cache directory speeds up repeated scans by storing the vulnerability database locally.
Filtering by Severity
To report only CRITICAL vulnerabilities:By default, Trivy exits with code
0 even if vulnerabilities are found. Use --exit-code to enforce build failures in CI/CD.Using Custom Exit Codes
Fail CI pipelines on CRITICAL issues:Integrating Trivy in a Jenkins Pipeline
Scan the base image before building and pushing Docker artifacts. Below is a sample declarative Jenkinsfile:Creating the Trivy Scan Script
Add a file namedtrivy-docker-image-scan.sh at the repository root:
Verifying in Jenkins
Commit and push your changes. Trigger a Jenkins build to see two parallel steps under the Vulnerability Scan – Docker stage:



