Docker Configuration Validator by rknall/claude-skills
npx skills add https://github.com/rknall/claude-skills --skill 'Docker Configuration Validator'此技能为 Dockerfile 和 Docker Compose 文件提供全面的验证,确保符合最佳实践、安全标准和现代语法要求。
当用户请求以下内容时激活此技能:
当用户请求 Docker 验证时,首先了解范围:
确定验证内容
理解需求
检查可用工具
查找项目中的所有 Dockerfile:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
find . -type f \( -name "Dockerfile*" ! -name "*.md" \)
如果 Hadolint 可用:
# 验证每个 Dockerfile
hadolint Dockerfile
# JSON 输出用于程序化分析
hadolint --format json Dockerfile
# 设置失败阈值
hadolint --failure-threshold error Dockerfile
如果 Hadolint 不可用:
检查每个 Dockerfile 的关键问题:
1. 基础镜像最佳实践
:latest 标签2. 多阶段构建验证
# 统计 FROM 语句(多阶段构建应 >= 2)
FROM_COUNT=$(grep -c "^FROM " Dockerfile)
# 检查命名阶段
NAMED_STAGES=$(grep -c "^FROM .* AS " Dockerfile)
# 检查阶段间复制
COPY_FROM=$(grep -c "COPY --from=" Dockerfile)
分析:
3. 安全检查
4. 层优化
5. 最佳实践
按严重性对发现的问题进行分类:
严重(必须修复):
:latest 标签高(应该修复):
中(推荐):
低(最好有):
查找所有 Docker Compose 文件:
find . -maxdepth 3 -type f \( -name "docker-compose*.yml" -o -name "docker-compose*.yaml" -o -name "compose*.yml" \)
关键检查: 现代 Docker Compose(v2.27.0+)不使用版本字段
# 检查过时的版本字段
if grep -q "^version:" docker-compose.yml; then
echo "❌ 错误:发现过时的 'version' 字段"
echo "移除 'version:' 行 - 它在 Compose v2.27.0+ 中已过时"
fi
旧(已弃用):
version: '3.8' # ❌ 移除此行
services:
web:
image: nginx:latest
新(现代):
# 没有版本字段!
services:
web:
image: nginx:1.24-alpine
# 语法验证
docker compose config --quiet
# 显示解析后的配置
docker compose config
# 验证特定文件
docker compose -f docker-compose.prod.yml config --quiet
# 检查 compose 文件
dclint docker-compose.yml
# 自动修复问题
dclint --fix docker-compose.yml
# JSON 输出
dclint --format json docker-compose.yml
1. 镜像最佳实践
:latest 标签2. 服务配置
3. 网络
4. 卷与持久化
5. 环境与密钥
6. 安全
验证多阶段构建时,确保:
1. 阶段结构
# 构建阶段
FROM node:20-bullseye AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build && npm run test
# 生产阶段
FROM node:20-alpine AS runtime
WORKDIR /app
COPY --from=builder /app/dist ./dist
USER node
CMD ["node", "dist/index.js"]
2. 验证清单
3. 要检查的常见模式
Node.js 多阶段:
Python 多阶段:
Go 多阶段:
执行全面的安全检查:
1. 用户与权限
# 检查 USER 指令
USER_COUNT=$(grep -c "^USER " Dockerfile)
LAST_USER=$(grep "^USER " Dockerfile | tail -1 | awk '{print $2}')
if [ "$USER_COUNT" -eq 0 ]; then
echo "❌ 严重:未指定 USER(以 root 身份运行!)"
elif [ "$LAST_USER" == "root" ] || [ "$LAST_USER" == "0" ]; then
echo "❌ 严重:最终的 USER 是 root"
fi
2. 暴露的密钥
3. 易受攻击的基础镜像
4. 网络暴露
构建验证报告:
# Docker 配置验证报告
## 执行摘要
- **分析的 Dockerfile 总数**:X
- **分析的 Compose 文件总数**:X
- **严重问题**:X
- **高优先级问题**:X
- **中优先级问题**:X
- **低优先级问题**:X
- **总体状态**:✅ 通过 / ⚠️ 警告 / ❌ 失败
## Dockerfile 分析
### [Dockerfile 路径]
#### 验证结果
✅ **通过**:实现了多阶段构建
✅ **通过**:以非 root 用户身份运行
⚠️ **警告**:使用 ADD 而非 COPY(第 15 行)
❌ **失败**:基础镜像使用 :latest 标签(第 1 行)
#### 安全评估
- **用户**:nodejs(非 root)✅
- **基础镜像**:node:latest ❌
- **密钥**:未检测到 ✅
- **健康检查**:存在 ✅
#### 多阶段构建分析
- **阶段数**:2(builder, runtime)
- **命名阶段**:是 ✅
- **阶段间复制**:1 ✅
- **最终基础镜像**:node:20-alpine ✅
- **最终镜像中的构建工具**:无 ✅
#### 发现的问题
**严重:**
1. 第 1 行:使用 :latest 标签
- 问题:`FROM node:latest`
- 修复:`FROM node:20-bullseye`
- 影响:构建不可预测,安全风险
**高:**
2. 第 45 行:未清理包缓存
- 问题:`RUN apt-get install -y curl`
- 修复:添加 `&& rm -rf /var/lib/apt/lists/*`
- 影响:镜像体积更大
**中:**
3. 第 15 行:使用 ADD 而非 COPY
- 问题:`ADD app.tar.gz /app/`
- 修复:`COPY app.tar.gz /app/`(或单独解压)
- 影响:行为不够明确
## Docker Compose 分析
### [Compose 文件路径]
#### 验证结果
❌ **失败**:存在过时的 'version' 字段
⚠️ **警告**:3 个服务使用 :latest 标签
✅ **通过**:定义了自定义网络
✅ **通过**:配置了命名卷
#### 现代语法合规性
- **版本字段**:存在 ❌(必须移除)
- **具体标签**:5 个服务中的 2 个 ⚠️
- **重启策略**:所有服务 ✅
- **健康检查**:5 个服务中的 3 个 ⚠️
#### 发现的问题
**严重:**
1. 过时的 'version' 字段
- 问题:`version: '3.8'`
- 修复:移除整行
- 影响:使用已弃用的语法
**高:**
2. 服务 'web' 使用 :latest 标签
- 问题:`image: nginx:latest`
- 修复:`image: nginx:1.24-alpine`
- 影响:部署不可预测
3. 服务 'cache' 没有重启策略
- 问题:缺少 `restart:` 指令
- 修复:添加 `restart: unless-stopped`
- 影响:服务不会自动恢复
## 建议
### 立即行动(严重)
1. 固定所有 Docker 镜像版本(移除 :latest)
2. 从 Compose 文件中移除过时的 'version' 字段
3. 确保所有服务以非 root 用户身份运行
4. 清理所有 Dockerfile 中的包管理器缓存
### 高优先级(生产前)
1. 为所有服务实现健康检查
2. 为所有 Compose 服务添加重启策略
3. 设置资源限制(内存、CPU)
4. 实现适当的密钥管理
### 中优先级(最佳实践)
1. 除非提取归档文件,否则使用 COPY 而非 ADD
2. 添加标签以更好地组织
3. 实现日志驱动程序
4. 为镜像添加元数据
### 低优先级(优化)
1. 在可能的情况下考虑使用更精简的基础镜像
2. 通过更好的排序优化层缓存
3. 添加全面的注释
4. 实现 .dockerignore 文件
## 后续步骤
1. **修复严重问题**(预计:30 分钟)
- 固定镜像版本
- 从 Compose 中移除版本字段
- 添加 USER 指令
2. **处理高优先级问题**(预计:1-2 小时)
- 添加健康检查
- 配置重启策略
- 设置资源限制
3. **重新验证**(预计:10 分钟)
- 修复后再次运行验证
- 确保所有严重问题已解决
4. **设置自动化**(预计:1 小时)
- 添加预提交钩子
- 集成到 CI/CD
- 安排定期安全扫描
## 验证工具推荐
### 安装所需工具
```bash
# Hadolint (Dockerfile 检查工具)
brew install hadolint # macOS
# 或
wget -O /usr/local/bin/hadolint https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
# DCLint (Docker Compose 检查工具)
npm install -g docker-compose-linter
# Trivy (安全扫描器)
brew install aquasecurity/trivy/trivy
[根据项目需求提供自定义验证脚本]
[提供 GitHub Actions / GitLab CI 配置]
## 交付物
验证结束时,提供:
1. **全面的验证报告**
- 包含总体状态的执行摘要
- 每个文件的详细发现
- 问题分类(严重 → 低)
- 每个问题的具体修复方法
- 优先排序的建议
2. **修复后的配置文件**(如请求)
- 修正后的 Dockerfile
- 更新后的 Compose 文件
- .hadolint.yaml 配置
- .dclintrc.json 配置
3. **验证脚本**(如请求)
- 用于自动化验证的自定义 bash 脚本
- 检查项目特定要求
- 彩色编码输出
- 用于 CI/CD 的退出代码
4. **CI/CD 集成**(如请求)
- GitHub Actions 工作流
- GitLab CI 配置
- 预提交钩子
- 与现有流水线的集成
5. **文档**
- 如何在本地运行验证
- 工具安装说明
- 最佳实践指南
- 常见问题及解决方案
## 验证脚本模板
当用户请求自动化验证时,创建此脚本:
```bash
#!/bin/bash
# docker-validation.sh
set -e
# 颜色代码
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
ERRORS=0
WARNINGS=0
echo -e "${BLUE}╔══════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Docker 配置验证器 ║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════╝${NC}"
# 1. 先决条件检查
echo -e "\n${BLUE}━━━ 检查先决条件 ━━━${NC}"
command -v docker >/dev/null || { echo "❌ 未找到 Docker"; exit 1; }
command -v hadolint >/dev/null || echo "⚠️ 未安装 Hadolint"
# 2. Dockerfile 验证
echo -e "\n${BLUE}━━━ 验证 Dockerfile ━━━${NC}"
find . -name "Dockerfile*" -type f | while read df; do
echo "检查:$df"
# [此处添加验证逻辑]
done
# 3. 多阶段构建检查
echo -e "\n${BLUE}━━━ 检查多阶段构建 ━━━${NC}"
# [多阶段验证逻辑]
# 4. Compose 验证
echo -e "\n${BLUE}━━━ 验证 Docker Compose ━━━${NC}"
find . -name "*compose*.yml" | while read cf; do
# 检查过时的版本字段
if grep -q "^version:" "$cf"; then
echo -e "${RED}❌ $cf:存在过时的版本字段${NC}"
ERRORS=$((ERRORS + 1))
fi
# 验证语法
docker compose -f "$cf" config --quiet || ERRORS=$((ERRORS + 1))
done
# 5. 安全检查
echo -e "\n${BLUE}━━━ 安全审计 ━━━${NC}"
# [安全验证逻辑]
# 最终报告
echo -e "\n${BLUE}╔══════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ 验证摘要 ║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════╝${NC}"
if [ $ERRORS -eq 0 ]; then
echo -e "${GREEN}✅ 所有检查通过!${NC}"
exit 0
else
echo -e "${RED}❌ 发现 $ERRORS 个错误,$WARNINGS 个警告${NC}"
exit 1
fi
name: Docker 验证
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 检查 Dockerfile
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: ./Dockerfile
failure-threshold: error
- name: 验证 Compose 文件
run: |
for f in $(find . -name "*compose*.yml"); do
docker compose -f "$f" config --quiet
done
- name: 检查过时的版本字段
run: |
if grep -r "^version:" . --include="*compose*.yml"; then
echo "错误:发现过时的版本字段"
exit 1
fi
stages:
- validate
docker-validation:
stage: validate
image: hadolint/hadolint:latest-debian
script:
- find . -name "Dockerfile*" -exec hadolint {} \;
- |
for f in $(find . -name "*compose*.yml"); do
if grep -q "^version:" "$f"; then
echo "错误:$f 中存在过时的版本字段"
exit 1
fi
done
进行验证时:
全面彻底
明确优先级
提供具体修复方法
教育引导
可操作性强
:latest 标签(DL3006):latest 标签提供建议时,参考:
记住:Docker 验证是为了确保容器化应用程序的可靠、安全和高效。在保持开发者体验的同时,始终优先考虑安全和生产就绪性。
每周安装次数
–
仓库
GitHub 星标数
33
首次出现时间
–
安全审计
This skill provides comprehensive validation for Dockerfiles and Docker Compose files, ensuring compliance with best practices, security standards, and modern syntax requirements.
Activate this skill when the user requests:
When a user requests Docker validation, start by understanding the scope:
Identify What to Validate
Understand Requirements
Check Available Tools
Find all Dockerfiles in the project:
find . -type f \( -name "Dockerfile*" ! -name "*.md" \)
If Hadolint is available:
# Validate each Dockerfile
hadolint Dockerfile
# JSON output for programmatic analysis
hadolint --format json Dockerfile
# Set failure threshold
hadolint --failure-threshold error Dockerfile
If Hadolint is NOT available:
Check each Dockerfile for critical issues:
1. Base Image Best Practices
:latest tags2. Multi-Stage Build Verification
# Count FROM statements (should be >= 2 for multi-stage)
FROM_COUNT=$(grep -c "^FROM " Dockerfile)
# Check for named stages
NAMED_STAGES=$(grep -c "^FROM .* AS " Dockerfile)
# Check for inter-stage copies
COPY_FROM=$(grep -c "COPY --from=" Dockerfile)
Analysis:
3. Security Checks
4. Layer Optimization
5. Best Practices
Classify findings by severity:
CRITICAL (Must Fix):
:latest tagsHIGH (Should Fix):
MEDIUM (Recommended):
LOW (Nice to Have):
Find all Docker Compose files:
find . -maxdepth 3 -type f \( -name "docker-compose*.yml" -o -name "docker-compose*.yaml" -o -name "compose*.yml" \)
CRITICAL CHECK: Modern Docker Compose (v2.27.0+) does NOT use version field
# Check for obsolete version field
if grep -q "^version:" docker-compose.yml; then
echo "❌ ERROR: Found obsolete 'version' field"
echo "Remove 'version:' line - it's obsolete in Compose v2.27.0+"
fi
Old (Deprecated):
version: '3.8' # ❌ REMOVE THIS
services:
web:
image: nginx:latest
New (Modern):
# No version field!
services:
web:
image: nginx:1.24-alpine
# Syntax validation
docker compose config --quiet
# Show resolved configuration
docker compose config
# Validate specific file
docker compose -f docker-compose.prod.yml config --quiet
# Lint compose file
dclint docker-compose.yml
# Auto-fix issues
dclint --fix docker-compose.yml
# JSON output
dclint --format json docker-compose.yml
1. Image Best Practices
:latest tags2. Service Configuration
3. Networking
4. Volumes & Persistence
5. Environment & Secrets
6. Security
When validating multi-stage builds, ensure:
1. Stage Structure
# Build stage
FROM node:20-bullseye AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build && npm run test
# Production stage
FROM node:20-alpine AS runtime
WORKDIR /app
COPY --from=builder /app/dist ./dist
USER node
CMD ["node", "dist/index.js"]
2. Validation Checklist
3. Common Patterns to Check
Node.js Multi-Stage:
Python Multi-Stage:
Go Multi-Stage:
Perform comprehensive security checks:
1. User & Permissions
# Check for USER directive
USER_COUNT=$(grep -c "^USER " Dockerfile)
LAST_USER=$(grep "^USER " Dockerfile | tail -1 | awk '{print $2}')
if [ "$USER_COUNT" -eq 0 ]; then
echo "❌ CRITICAL: No USER specified (runs as root!)"
elif [ "$LAST_USER" == "root" ] || [ "$LAST_USER" == "0" ]; then
echo "❌ CRITICAL: Final USER is root"
fi
2. Exposed Secrets
3. Vulnerable Base Images
4. Network Exposure
Structure the validation report:
# Docker Configuration Validation Report
## Executive Summary
- **Total Dockerfiles Analyzed**: X
- **Total Compose Files Analyzed**: X
- **Critical Issues**: X
- **High Priority Issues**: X
- **Medium Priority Issues**: X
- **Low Priority Issues**: X
- **Overall Status**: ✅ PASS / ⚠️ WARNINGS / ❌ FAIL
## Dockerfile Analysis
### [Dockerfile Path]
#### Validation Results
✅ **PASSED**: Multi-stage build implemented
✅ **PASSED**: Running as non-root user
⚠️ **WARNING**: Using ADD instead of COPY (line 15)
❌ **FAILED**: Base image uses :latest tag (line 1)
#### Security Assessment
- **User**: nodejs (non-root) ✅
- **Base Image**: node:latest ❌
- **Secrets**: None detected ✅
- **Health Check**: Present ✅
#### Multi-Stage Build Analysis
- **Stages**: 2 (builder, runtime)
- **Named Stages**: Yes ✅
- **Inter-Stage Copies**: 1 ✅
- **Final Base**: node:20-alpine ✅
- **Build Tools in Final**: No ✅
#### Issues Found
**CRITICAL:**
1. Line 1: Using :latest tag
- Issue: `FROM node:latest`
- Fix: `FROM node:20-bullseye`
- Impact: Unpredictable builds, security risk
**HIGH:**
2. Line 45: Package cache not cleaned
- Issue: `RUN apt-get install -y curl`
- Fix: Add `&& rm -rf /var/lib/apt/lists/*`
- Impact: Larger image size
**MEDIUM:**
3. Line 15: Using ADD instead of COPY
- Issue: `ADD app.tar.gz /app/`
- Fix: `COPY app.tar.gz /app/` (or extract separately)
- Impact: Less explicit behavior
## Docker Compose Analysis
### [Compose File Path]
#### Validation Results
❌ **FAILED**: Obsolete 'version' field present
⚠️ **WARNING**: 3 services using :latest tags
✅ **PASSED**: Custom networks defined
✅ **PASSED**: Named volumes configured
#### Modern Syntax Compliance
- **Version Field**: Present ❌ (MUST REMOVE)
- **Specific Tags**: 2 of 5 services ⚠️
- **Restart Policies**: All services ✅
- **Health Checks**: 3 of 5 services ⚠️
#### Issues Found
**CRITICAL:**
1. Obsolete 'version' field
- Issue: `version: '3.8'`
- Fix: Remove the entire line
- Impact: Using deprecated syntax
**HIGH:**
2. Service 'web' uses :latest tag
- Issue: `image: nginx:latest`
- Fix: `image: nginx:1.24-alpine`
- Impact: Unpredictable deployments
3. No restart policy on 'cache' service
- Issue: Missing `restart:` directive
- Fix: Add `restart: unless-stopped`
- Impact: Service won't auto-recover
## Recommendations
### Immediate Actions (Critical)
1. Pin all Docker image versions (remove :latest)
2. Remove obsolete 'version' field from Compose files
3. Ensure all services run as non-root users
4. Clean package manager caches in all Dockerfiles
### High Priority (Before Production)
1. Implement health checks for all services
2. Add restart policies to all Compose services
3. Set up resource limits (memory, CPU)
4. Implement proper secrets management
### Medium Priority (Best Practices)
1. Use COPY instead of ADD unless extracting archives
2. Add labels for better organization
3. Implement logging drivers
4. Add metadata to images
### Low Priority (Optimizations)
1. Consider slimmer base images where possible
2. Optimize layer caching with better ordering
3. Add comprehensive comments
4. Implement .dockerignore files
## Next Steps
1. **Fix Critical Issues** (Estimated: 30 minutes)
- Pin image versions
- Remove version field from Compose
- Add USER directives
2. **Address High Priority** (Estimated: 1-2 hours)
- Add health checks
- Configure restart policies
- Set resource limits
3. **Re-validate** (Estimated: 10 minutes)
- Run validation again after fixes
- Ensure all critical issues resolved
4. **Set Up Automation** (Estimated: 1 hour)
- Add pre-commit hooks
- Integrate into CI/CD
- Schedule regular security scans
## Validation Tools Recommendations
### Install Required Tools
```bash
# Hadolint (Dockerfile linter)
brew install hadolint # macOS
# or
wget -O /usr/local/bin/hadolint https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
# DCLint (Docker Compose linter)
npm install -g docker-compose-linter
# Trivy (Security scanner)
brew install aquasecurity/trivy/trivy
[Provide custom validation script based on project needs]
[Provide GitHub Actions / GitLab CI configuration]
## Deliverables
At the end of validation, provide:
1. **Comprehensive Validation Report**
- Executive summary with overall status
- Detailed findings per file
- Issue classification (Critical → Low)
- Specific fixes for each issue
- Recommendations prioritized
2. **Fixed Configuration Files** (if requested)
- Corrected Dockerfiles
- Updated Compose files
- .hadolint.yaml configuration
- .dclintrc.json configuration
3. **Validation Script** (if requested)
- Custom bash script for automated validation
- Checks for project-specific requirements
- Color-coded output
- Exit codes for CI/CD
4. **CI/CD Integration** (if requested)
- GitHub Actions workflow
- GitLab CI configuration
- Pre-commit hooks
- Integration with existing pipeline
5. **Documentation**
- How to run validation locally
- Tool installation instructions
- Best practices guide
- Common issues and solutions
## Validation Script Template
When user requests automated validation, create this script:
```bash
#!/bin/bash
# docker-validation.sh
set -e
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
ERRORS=0
WARNINGS=0
echo -e "${BLUE}╔══════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Docker Configuration Validator ║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════╝${NC}"
# 1. Prerequisites check
echo -e "\n${BLUE}━━━ Checking Prerequisites ━━━${NC}"
command -v docker >/dev/null || { echo "❌ Docker not found"; exit 1; }
command -v hadolint >/dev/null || echo "⚠️ Hadolint not installed"
# 2. Dockerfile validation
echo -e "\n${BLUE}━━━ Validating Dockerfiles ━━━${NC}"
find . -name "Dockerfile*" -type f | while read df; do
echo "Checking: $df"
# [Validation logic here]
done
# 3. Multi-stage build check
echo -e "\n${BLUE}━━━ Checking Multi-Stage Builds ━━━${NC}"
# [Multi-stage validation logic]
# 4. Compose validation
echo -e "\n${BLUE}━━━ Validating Docker Compose ━━━${NC}"
find . -name "*compose*.yml" | while read cf; do
# Check for obsolete version field
if grep -q "^version:" "$cf"; then
echo -e "${RED}❌ $cf: Obsolete version field${NC}"
ERRORS=$((ERRORS + 1))
fi
# Validate syntax
docker compose -f "$cf" config --quiet || ERRORS=$((ERRORS + 1))
done
# 5. Security checks
echo -e "\n${BLUE}━━━ Security Audit ━━━${NC}"
# [Security validation logic]
# Final report
echo -e "\n${BLUE}╔══════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Validation Summary ║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════╝${NC}"
if [ $ERRORS -eq 0 ]; then
echo -e "${GREEN}✅ All checks passed!${NC}"
exit 0
else
echo -e "${RED}❌ Found $ERRORS error(s), $WARNINGS warning(s)${NC}"
exit 1
fi
name: Docker Validation
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint Dockerfiles
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: ./Dockerfile
failure-threshold: error
- name: Validate Compose files
run: |
for f in $(find . -name "*compose*.yml"); do
docker compose -f "$f" config --quiet
done
- name: Check for obsolete version field
run: |
if grep -r "^version:" . --include="*compose*.yml"; then
echo "ERROR: Found obsolete version field"
exit 1
fi
stages:
- validate
docker-validation:
stage: validate
image: hadolint/hadolint:latest-debian
script:
- find . -name "Dockerfile*" -exec hadolint {} \;
- |
for f in $(find . -name "*compose*.yml"); do
if grep -q "^version:" "$f"; then
echo "ERROR: Obsolete version field in $f"
exit 1
fi
done
When conducting validation:
Be Thorough
Prioritize Clearly
Provide Specific Fixes
Educate
Be Actionable
:latest tags (DL3006):latest tagsWhen providing recommendations, reference:
Remember: Docker validation is about ensuring reliable, secure, and efficient containerized applications. Always prioritize security and production readiness while maintaining developer experience.
Weekly Installs
–
Repository
GitHub Stars
33
First Seen
–
Security Audits
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
114,200 周安装
产品经理工具包:RICE优先级排序、客户访谈分析与PRD模板,提升产品管理效率
377 周安装
AI代理团队简化与加固代码审查:自动化两阶段循环提升生产级代码质量
377 周安装
红队战术指南:基于MITRE ATT&CK框架的对手模拟与渗透测试技能
375 周安装
loki-mode:claudiodearaujo/izacenter 开发的代码编辑器增强工具,提升开发效率
1 周安装
Zod 4 中文指南:TypeScript 运行时类型验证库从 v3 到 v4 升级教程
378 周安装
Spring缓存单元测试指南:@Cacheable、@CacheEvict、@CachePut测试方法与内存缓存管理器
376 周安装