Scanning Container Security
Overview
Scan container images and Dockerfiles for vulnerabilities, misconfigurations, and compliance violations using Trivy, Grype, Snyk Container, and Hadolint. Analyze base images, OS packages, application dependencies, and runtime configurations to produce actionable security reports with remediation guidance.
Prerequisites
- Container scanning tool installed:
trivy, grype, snyk, or docker scout
- Dockerfile linter:
hadolint for Dockerfile best practice validation
- Docker daemon running for local image scanning
- Access to the container images to scan (local, registry, or tar archive)
jq for parsing JSON scan results
Instructions
- Identify target images for scanning: production images, base images, and CI-built images
- Lint Dockerfiles with
hadolint Dockerfile to catch misconfigurations before build (privileged instructions, pinned versions, shell best practices)
- Scan built images for OS-level vulnerabilities:
trivy image <image:tag> or grype <image:tag>
- Scan for application dependency vulnerabilities: check language-specific packages (npm, pip, Maven, Go modules) embedded in the image
- Check for secrets accidentally baked into image layers:
trivy image --scanners secret <image:tag>
- Evaluate image against CIS Docker Benchmark: verify non-root user, read-only filesystem capability, health checks defined
- Generate a security report with severity classification (Critical, High, Medium, Low) and CVE identifiers
- Produce remediation steps: upgrade base image, pin package versions, replace vulnerable dependencies
- Integrate scanning into CI/CD pipeline: fail builds on Critical/High vulnerabilities, generate SARIF output for GitHub Security tab
Output
- Vulnerability scan report in JSON, table, or SARIF format
- Hadolint report with Dockerfile improvement recommendations
- Remediation Dockerfile patches (updated base image, pinned package versions)
- CI/CD pipeline step configuration for automated image scanning
- Security policy document defining acceptable risk thresholds
Error Handling
| Error |
Cause |
Solution |
trivy: unable to pull image |
Image not found locally or registry auth failure |
Pull image first with docker pull or configure registry credentials |
CRITICAL vulnerability found but no fix available |
Upstream package has no patch yet |
Document as accepted risk, use --ignore-unfixed flag, or switch to an alternative base image |
hadolint: DL3008 pin versions in apt-get install |
Packages installed without version pinning |
Add version pins (e.g., apt-get install nginx=1.24.0-1) or use --no-install-recommends |
Scan timeout on large image |
Image has many layers or large filesystem |
Use --timeout 15m flag; scan a specific layer or use --skip-dirs to exclude test data |
False positive CVE |
Scanner database maps CVE to a package not actually exploitable |
Add to .trivyignore or Grype ignore file with justification comment |
Examples
- "Scan all production Docker images for Critical and High CVEs, generate a report, and create Jira tickets for each finding."
- "Lint the Dockerfile for best practices: ensure multi-stage build, non-root USER, no ADD for remote URLs, and pinned base image digest."
- "Set up a GitHub Actions step that runs Trivy on every PR, fails on Critical vulnerabilities, and uploads results to the Security tab via SARIF."
Resources
Source: jeremylongshore/claude-code-plugins-plus-skills → skills/.curated/scanning-container-security/SKILL.md
Also appears in: jeremylongshore/claude-code-plugins-plus-skills/plugins/devops/container-security-scanner/skills/scanning-container-security/SKILL.md
1---2name: scanning-container-security3description: 'Execute use when you need to work with security and compliance. This skill provides security scanning and vulnerability detection with comprehensive guidance and automation. Trigger with phrases like "scan for vulnerabilities", "implement security controls", or "audit security". '4---5
6# Scanning Container Security
7
8## Overview
9
10Scan container images and Dockerfiles for vulnerabilities, misconfigurations, and compliance violations using Trivy, Grype, Snyk Container, and Hadolint. Analyze base images, OS packages, application dependencies, and runtime configurations to produce actionable security reports with remediation guidance.
11
12## Prerequisites
13
14- Container scanning tool installed: `trivy`, `grype`, `snyk`, or `docker scout`
15- Dockerfile linter: `hadolint` for Dockerfile best practice validation
16- Docker daemon running for local image scanning
17- Access to the container images to scan (local, registry, or tar archive)
18- `jq` for parsing JSON scan results
19
20## Instructions
21
221. Identify target images for scanning: production images, base images, and CI-built images
232. Lint Dockerfiles with `hadolint Dockerfile` to catch misconfigurations before build (privileged instructions, pinned versions, shell best practices)
243. Scan built images for OS-level vulnerabilities: `trivy image <image:tag>` or `grype <image:tag>`
254. Scan for application dependency vulnerabilities: check language-specific packages (npm, pip, Maven, Go modules) embedded in the image
265. Check for secrets accidentally baked into image layers: `trivy image --scanners secret <image:tag>`
276. Evaluate image against CIS Docker Benchmark: verify non-root user, read-only filesystem capability, health checks defined
287. Generate a security report with severity classification (Critical, High, Medium, Low) and CVE identifiers
298. Produce remediation steps: upgrade base image, pin package versions, replace vulnerable dependencies
309. Integrate scanning into CI/CD pipeline: fail builds on Critical/High vulnerabilities, generate SARIF output for GitHub Security tab
31
32## Output
33
34- Vulnerability scan report in JSON, table, or SARIF format
35- Hadolint report with Dockerfile improvement recommendations
36- Remediation Dockerfile patches (updated base image, pinned package versions)
37- CI/CD pipeline step configuration for automated image scanning
38- Security policy document defining acceptable risk thresholds
39
40## Error Handling
41
42| Error | Cause | Solution |
43|-------|-------|---------|
44| `trivy: unable to pull image` | Image not found locally or registry auth failure | Pull image first with `docker pull` or configure registry credentials |
45| `CRITICAL vulnerability found but no fix available` | Upstream package has no patch yet | Document as accepted risk, use `--ignore-unfixed` flag, or switch to an alternative base image |
46| `hadolint: DL3008 pin versions in apt-get install` | Packages installed without version pinning | Add version pins (e.g., `apt-get install nginx=1.24.0-1`) or use `--no-install-recommends` |
47| `Scan timeout on large image` | Image has many layers or large filesystem | Use `--timeout 15m` flag; scan a specific layer or use `--skip-dirs` to exclude test data |
48| `False positive CVE` | Scanner database maps CVE to a package not actually exploitable | Add to `.trivyignore` or Grype ignore file with justification comment |
49
50## Examples
51
52- "Scan all production Docker images for Critical and High CVEs, generate a report, and create Jira tickets for each finding."
53- "Lint the Dockerfile for best practices: ensure multi-stage build, non-root USER, no ADD for remote URLs, and pinned base image digest."
54- "Set up a GitHub Actions step that runs Trivy on every PR, fails on Critical vulnerabilities, and uploads results to the Security tab via SARIF."
55
56## Resources
57
58- Trivy: https://aquasecurity.github.io/trivy/
59- Grype: https://github.com/anchore/grype
60- Hadolint: https://github.com/hadolint/hadolint
61- Docker Scout: https://docs.docker.com/scout/
62- CIS Docker Benchmark: https://www.cisecurity.org/benchmark/docker
63
64---
65
66**Source:** [`jeremylongshore/claude-code-plugins-plus-skills`](https://github.com/jeremylongshore/claude-code-plugins-plus-skills) → `skills/.curated/scanning-container-security/SKILL.md`
67
68**Also appears in:** `jeremylongshore/claude-code-plugins-plus-skills/plugins/devops/container-security-scanner/skills/scanning-container-security/SKILL.md`