Skip to content
Skillpedia
Agents35k · #6195

scanning-docker-images-with-trivy

Has your agent scan container images for vulnerabilities and errors. It can generate reports and prevent the use of insecure images.

What it does

Checks container images (like those used to run applications online) for security issues such as known flaws, misconfigurations, or exposed sensitive information. It helps ensure your applications are protected.

When to use it

  • ✓When checking the security of a container image before using it.
  • ✓When integrating security checks into automatic development and deployment processes.
  • ✓When investigating a security incident that might be related to a container image.

Example of what to ask your AI

“Scan the 'my-app:latest' image for critical and high vulnerabilities.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/scanning-docker-images-with-trivy/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/scanning-docker-images-with-trivy/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

Trivy analyzes the components within the container image, comparing them against databases of known vulnerabilities. It also looks for insecure settings and exposed secrets.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill scanning-docker-images-with-trivy

Or download just the file:

curl -L https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/main/skills/scanning-docker-images-with-trivy/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Scanning Docker Images with Trivy

Overview

Trivy is a comprehensive open-source vulnerability scanner by Aqua Security that detects vulnerabilities in OS packages, language-specific dependencies, misconfigurations, secrets, and license violations within container images. It integrates into CI/CD pipelines and supports multiple output formats including SARIF, CycloneDX, and SPDX.

When to Use

  • When conducting security assessments that involve scanning docker images with trivy
  • When following incident response procedures for related security events
  • When performing scheduled security testing or auditing activities
  • When validating security controls through hands-on testing

Prerequisites

  • Docker Engine 20.10+
  • Trivy v0.50+ installed
  • Internet access for vulnerability database updates
  • Container registry credentials (for private registries)

Core Concepts

Scanner Types

Scanner Flag Detects
Vulnerability --scanners vuln CVEs in OS packages and libraries
Misconfiguration --scanners misconfig Dockerfile/K8s manifest misconfigs
Secret --scanners secret Hardcoded passwords, API keys, tokens
License --scanners license Software license compliance issues

Severity Levels

  • CRITICAL: CVSS 9.0-10.0 - Immediate action required
  • HIGH: CVSS 7.0-8.9 - Fix before production deployment
  • MEDIUM: CVSS 4.0-6.9 - Plan remediation
  • LOW: CVSS 0.1-3.9 - Accept or fix opportunistically
  • UNKNOWN: Unscored - Evaluate manually

Vulnerability Database

Trivy uses multiple vulnerability databases:

  • NVD (National Vulnerability Database)
  • Red Hat Security Data
  • Alpine SecDB
  • Debian Security Tracker
  • Ubuntu CVE Tracker
  • Amazon Linux Security Center
  • GitHub Advisory Database

Workflow

Step 1: Install Trivy

# Linux (apt)
sudo apt-get install wget apt-transport-https gnupg lsb-release
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 $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update && sudo apt-get install trivy

# macOS
brew install trivy

# Docker
docker pull aquasecurity/trivy:latest

Step 2: Basic Image Scanning

# Scan a public image
trivy image python:3.12-slim

# Scan with severity filter
trivy image --severity CRITICAL,HIGH nginx:latest

# Ignore unfixed vulnerabilities
trivy image --ignore-unfixed alpine:3.19

# Scan local image
docker build -t myapp:latest .
trivy image myapp:latest

# Scan from tar archive
docker save myapp:latest -o myapp.tar
trivy image --input myapp.tar

Step 3: Advanced Scanning Options

# All scanners (vuln + misconfig + secret + license)
trivy image --scanners vuln,misconfig,secret,license myapp:latest

# Generate SBOM in CycloneDX format
trivy image --format cyclonedx --output sbom.cdx.json myapp:latest

# Generate SBOM in SPDX format
trivy image --format spdx-json --output sbom.spdx.json myapp:latest

# JSON output for programmatic processing
trivy image --format json --output results.json myapp:latest

# SARIF output for GitHub Security tab
trivy image --format sarif --output results.sarif myapp:latest

# Template-based output
trivy image --format template --template "@contrib/html.tpl" --output report.html myapp:latest

# Scan specific layers only
trivy image --list-all-pkgs myapp:latest

Step 4: Scanning Kubernetes Manifests

# Scan Dockerfile for misconfigurations
trivy config Dockerfile

# Scan Kubernetes manifests
trivy config k8s-deployment.yaml

# Scan Helm charts
trivy config ./helm-chart/

# Scan Terraform files
trivy config ./terraform/

Step 5: CI/CD Integration

# GitHub Actions
name: Trivy Container Scan
on: push

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build 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 Trivy scan results
        uses: github/codeql-action/upload-sarif@v3

…
FAQ

What is a container image?

It's a package containing everything a program needs to run, like its code, libraries, and settings, allowing it to work the same way anywhere.

What are vulnerabilities?

These are security flaws in software that hackers can exploit to cause harm or steal information.

What are misconfigurations?

These are incorrect settings in systems or software that can create security gaps, even if the software itself has no known flaws.

Details

Original description by the author

Scans a Docker image with Trivy for vulnerabilities in OS packages and language dependencies, misconfiguration, exposed secrets, and licence violations, emitting SARIF, CycloneDX, or SPDX output. Use when scanning or gating a specific image, wiring an image scan into CI/CD, or checking an image during an incident investigation. Keywords: Trivy, image scan, --severity, --exit-code, SARIF, ignore fi

repo: mukul975/Anthropic-Cybersecurity-Skills

Popularity

GitHub stars
35k
Ranking position
#6195
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills