---
name: docker-container-analyzer
description: "Assesses a container image before it ships: base image risk, known vulnerabilities to check, layer and size findings, and runtime hardening steps, in a short report a reviewer can sign off. Use when a container image needs a security and size assessment before deployment, with base image risk, CVEs to check, and runtime hardening. Do not use for troubleshooting a container that is already failing, or rewriting a Dockerfile to shrink the image. Related topics: coding, docker."
---

# Docker Container Analyzer

Assesses a container image before it ships: base image risk, known vulnerabilities to check, layer and size findings, and runtime hardening steps, in a short report a reviewer can sign off.

## When to use

Use this skill when a container image needs a security and size assessment before deployment, with base image risk, CVEs to check, and runtime hardening. Do not use it for troubleshooting a container that is already failing, or rewriting a Dockerfile to shrink the image.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Read the supplied layer history or Dockerfile for packages, secrets, and copied files, or state that findings rest on name, tag, and base OS and give the commands to confirm.
3. Judge the base image on tag pinning, end-of-life status, and package surface, and record each finding as a bullet.
4. List CVE IDs when lookup is enabled, each labelled known or to be confirmed by a scanner.
5. Compare the image size to the limit and attribute any excess to specific layers.
6. Write the hardening recommendations in priority order and open the report with a one-line verdict.

## Inputs

- **Image name** (free text, e.g. "nginx or ghcr.io/acme/api")
- **Tag** (free text, e.g. "1.27.2 or latest")
- **Base OS** (choose one: Alpine, Debian, Ubuntu, CentOS, Distroless, Scratch, Unknown)
- **Analysis depth** (choose one: Quick, Moderate, Deep)
- **CVE lookup** (choose one: Enable, Disable)
- **Size limit (MB)** (number from 0 to 2000)
- **Image history or Dockerfile** (longer free text)
- **Additional notes** (longer free text)

## Output

A Markdown report with sections Summary (one-line verdict), Security Findings, Size Overview, and Recommendations, all in bullet points, with CVE IDs when lookup is enabled.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Docker Container Analyzer

Assess this container image for security and size before deployment.

- Image name: {{Image name}}
- Tag: {{Tag}}
- Base OS: {{Base OS}}
- Analysis depth: {{Analysis depth}}
- CVE lookup: {{CVE lookup}}
- Size limit (MB): {{Size limit (MB)}}
- Image history or Dockerfile: {{Image history or Dockerfile}}
- Additional notes: {{Additional notes}}

Work from what is actually supplied: when the history or Dockerfile is present, read every layer for packages, secrets, and files copied in; when it is not, say that findings are based on the image name, tag, and base OS, and give the commands (docker history, docker inspect, a scanner such as trivy or grype) that would confirm them. Judge the base image on tag pinning (latest is a finding in itself), end-of-life status, and the size of its package surface. When CVE lookup is enabled, name the CVE IDs you know to apply to that base and version and label each as known or to be confirmed by the scanner. Compare the size to the limit and attribute the excess to specific layers where possible. Recommend runtime hardening in priority order: non-root user, read-only filesystem, dropped capabilities, no secrets in environment, a health check. Scale the detail to the chosen depth. Write the report with sections Summary (verdict in one line), Security Findings, Size Overview, and Recommendations, bullets only.

## Pitfalls

- Presenting remembered CVEs as scan results; label what a scanner must confirm so nobody signs off on a guess.
- Passing an image tagged latest, which makes every finding unreproducible the next time the tag moves.
- Burying the verdict under findings; the reviewer needs the ship or do not ship line first.
