Course contentsShow
← Security
Lesson 1400 of 3,05228. Application Security - TestingFree lesson

Container and Image Scanning

Implementing automated container image scanning, base image policies, and vulnerability management for containerized applications.

Container and Image Scanning

You'll learn how automated container image scanning catches vulnerabilities before they reach production.

What This Is

Container and image scanning analyzes Docker images, OCI-format containers, and base layers for known vulnerabilities, malware, misconfigurations, and embedded secrets. Unlike runtime security, this happens during the build phase—before containers ever deploy.

Think of it like airport security scanning luggage before passengers board, rather than during the flight. You catch problems when they're easiest to fix.

How Container Scanning Works

Scanners extract filesystem layers from container images and compare installed packages against vulnerability databases (CVE feeds, OS vendor advisories). They detect:

  • Vulnerable packages in base images (outdated openssl, curl, etc.)
  • Embedded secrets accidentally baked into layers
  • Misconfigurations like running as root or exposed ports
  • Malware signatures in binaries

You've already used tools like Trivy and Grype that handle this—they scan both dependencies and container layers.

Base Image Policies

Organizations enforce base image standards:

  • Approved base images only (vetted, minimal OS layers)
  • Automatic rebuilds when upstream patches release
  • Maximum age policies (reject images >30 days old)
  • Severity thresholds (block critical/high vulnerabilities)

This prevents developers from using random Docker Hub images with unknown provenance.

Pipeline Integration

Container scanning fits naturally into CI/CD:

  1. Build image
  2. Scan image (fail build if critical vulnerabilities found)
  3. Push only clean images to registry
  4. Continuous registry scanning (new CVEs emerge daily)

Registry platforms like Docker Hub, ECR, and Harbor often include built-in scanning.

Key Takeaway: Container scanning shifts left by catching vulnerabilities in images during build time, using base image policies and automated scans to prevent vulnerable containers from reaching production.