🐳Container Image Scanning Labs

🎯 Objective

Use Aqua Security's Trivy to scan container images for vulnerabilities, misconfigurations, and exposed secrets.


🧰 Prerequisites

  • Docker installed

  • Internet access

  • Trivy installed (brew install trivy or sudo apt install trivy)


πŸ”Ή Lab 1: Install Trivy

brew install aquasecurity/trivy/trivy

πŸ”Ή Lab 2: Scan a Public Image

trivy image nginx:latest

βœ… Trivy outputs known vulnerabilities (CVEs), their severity, and fixed versions.


πŸ”Ή Lab 3: Scan a Local Image

Step 1: Build your own image

Create the Dockerfile:

Build the container image:

Step 2: Scan the local image

βœ… Scan custom images before pushing to production.


πŸ”Ή Lab 4: Scan for Secrets and Misconfigurations

βœ… Trivy also finds secrets and insecure configs in layers.


πŸ”Ή Lab 5: Generate Reports in Different Formats

Step 1: Use JSON output

Step 2: Use CycloneDx output (for SBOM)

βœ… Useful for automation in CI pipelines and to report SBOM files as part of supply chain security.


πŸ”Ή Lab 6: Integrate with CI/CD (GitHub Actions) β€” Optional


βœ… Wrap-Up

  • βœ… Installed and used Trivy to scan public and private images

  • βœ… Detected CVEs, misconfigurations, and secrets

  • βœ… Generated reports for review and CI use


Last updated