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.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
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
USER rootwithout switching back - MUST flag secrets in ENV, ARG, or COPY (API keys, passwords)
- MUST flag
apt-get installwithout--no-install-recommends - Flag missing
USERdirective (runs as root by default) - Flag
COPY . .(may include secrets, .git, etc.) - Flag
:latesttags (unpinned versions) - Flag
curl | shpatterns
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 -
.dockerignorefile exists and covers .git, node_modules, etc. -
apt-get clean && rm -rf /var/lib/apt/lists/*in same layer
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
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!