Claude-skill-registry dockerfile-review
Review Dockerfiles for best practices, security, and optimization. Use when the user says "review Dockerfile", "optimize image", "Dockerfile best practices", "reduce image size", or asks to audit a container build.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/dockerfile-review" ~/.claude/skills/majiayu000-claude-skill-registry-dockerfile-review && rm -rf "$T"
manifest:
skills/data/dockerfile-review/SKILL.mdsource content
Dockerfile Review
Audit Dockerfiles for security, efficiency, and best practices.
Instructions
- Read the Dockerfile
- Check for issues in each category below
- Report findings with severity (critical/warning/suggestion)
- Provide specific fixes with corrected code
Security checks
- MUST flag
without switching backUSER root - MUST flag secrets in ENV, ARG, or COPY (API keys, passwords)
- MUST flag
withoutapt-get install--no-install-recommends - Flag missing
directive (runs as root by default)USER - Flag
(may include secrets, .git, etc.)COPY . . - Flag
tags (unpinned versions):latest - Flag
patternscurl | sh
Optimization checks
- Multi-stage builds for compiled languages
- Layer ordering (least-changing first)
- Combined RUN statements to reduce layers
- Cache mounts for package managers:
--mount=type=cache
file exists and covers .git, node_modules, etc..dockerignore
in same layerapt-get clean && rm -rf /var/lib/apt/lists/*
Best practices
# Good: pinned, non-root, minimal FROM python:3.11-slim@sha256:abc123... WORKDIR /app RUN useradd -r -s /bin/false appuser COPY requirements.txt . RUN --mount=type=cache,target=/root/.cache/pip \ pip install -r requirements.txt COPY --chown=appuser:appuser . . USER appuser CMD ["python", "app.py"]
Output format
## Critical - Line 5: Running as root without USER directive ## Warnings - Line 12: Using :latest tag - pin to specific version ## Suggestions - Line 8-10: Combine RUN statements to reduce layers
Rules
- MUST read the Dockerfile before reviewing
- MUST categorize issues by severity
- Never approve Dockerfiles with hardcoded secrets
- Always check for corresponding .dockerignore