jpskill.com
🛠️ 開発・MCP コミュニティ

container-hadolint

Dockerfileのセキュリティ上の問題点やアンチパターンを、100以上のルールに基づいてチェックし、CIS Docker Benchmarkへの準拠状況も確認、セキュリティベストプラクティスを適用するための修正ガイダンスを提供するSkill。

📜 元の英語説明(参考)

Dockerfile security linting and best practice validation using Hadolint with 100+ built-in rules aligned to CIS Docker Benchmark. Use when: (1) Analyzing Dockerfiles for security misconfigurations and anti-patterns, (2) Enforcing container image security best practices in CI/CD pipelines, (3) Detecting hardcoded secrets and credentials in container builds, (4) Validating compliance with CIS Docker Benchmark requirements, (5) Integrating shift-left container security into developer workflows, (6) Providing remediation guidance for insecure Dockerfile instructions.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Dockerfileのセキュリティ上の問題点やアンチパターンを、100以上のルールに基づいてチェックし、CIS Docker Benchmarkへの準拠状況も確認、セキュリティベストプラクティスを適用するための修正ガイダンスを提供するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o container-hadolint.zip https://jpskill.com/download/17022.zip && unzip -o container-hadolint.zip && rm container-hadolint.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17022.zip -OutFile "$d\container-hadolint.zip"; Expand-Archive "$d\container-hadolint.zip" -DestinationPath $d -Force; ri "$d\container-hadolint.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して container-hadolint.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → container-hadolint フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
8

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Hadolint を使用した Dockerfile のセキュリティリント

概要

Hadolint は、セキュリティのベストプラクティスと CIS Docker Benchmark に照らしてコンテナビルドファイルを検証する Dockerfile リンターです。Dockerfile の命令を分析し、イメージがビルドおよびデプロイされる前に、構成ミス、アンチパターン、セキュリティ脆弱性を特定します。

Hadolint は ShellCheck を統合して RUN 命令を検証し、シェルコマンドがセキュリティのベストプラクティスに従っていることを確認します。CIS Docker Benchmark の制御にマッピングされた 100 以上の組み込みルールにより、Hadolint はコンテナイメージに対する包括的なセキュリティ検証を提供します。

クイックスタート

Hadolint のインストール

# macOS via Homebrew
brew install hadolint

# Linux via binary
wget -O /usr/local/bin/hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64
chmod +x /usr/local/bin/hadolint

# Via Docker
docker pull hadolint/hadolint

Dockerfile のスキャン

# 現在のディレクトリにある Dockerfile をスキャン
hadolint Dockerfile

# 特定の Dockerfile パスでスキャン
hadolint path/to/Dockerfile

# Docker の使用
docker run --rm -i hadolint/hadolint < Dockerfile

レポートの生成

# 自動化のための JSON 出力
hadolint -f json Dockerfile > hadolint-report.json

# GitLab Code Quality 形式
hadolint -f gitlab_codeclimate Dockerfile > hadolint-codeclimate.json

# CI 統合のための Checkstyle 形式
hadolint -f checkstyle Dockerfile > hadolint-checkstyle.xml

コアワークフロー

1. ローカル開発スキャン

開発中に Dockerfile を検証します。

# 色付き出力による基本的なスキャン
hadolint Dockerfile

# 特定の重大度しきい値でスキャン
hadolint --failure-threshold error Dockerfile

# 警告とエラーのみを表示
hadolint --no-color --format tty Dockerfile | grep -E "^(warning|error)"

# ルール ID を含む詳細な出力
hadolint -t style -t warning -t error Dockerfile

出力形式:

Dockerfile:3 DL3008 warning: Pin versions in apt get install
Dockerfile:7 DL3025 error: Use JSON notation for CMD and ENTRYPOINT
Dockerfile:12 DL3059 info: Multiple RUN instructions detected

使用するタイミング: 開発者のワークステーション、コミット前の検証、反復的な Dockerfile 開発。

2. CI/CD パイプラインの統合

ビルドパイプラインで Dockerfile の検証を自動化します。

GitHub Actions

name: Hadolint
on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Hadolint Dockerfile
        uses: hadolint/hadolint-action@v3.1.0
        with:
          dockerfile: Dockerfile
          failure-threshold: warning
          format: sarif
          output-file: hadolint.sarif

      - name: Upload SARIF to GitHub Security
        if: always()
        uses: github/codeql-action/upload-sarif@v2
        with:
          sarif_file: hadolint.sarif

GitLab CI

hadolint:
  image: hadolint/hadolint:latest-debian
  stage: lint
  script:
    - hadolint -f gitlab_codeclimate Dockerfile > hadolint-report.json
  artifacts:
    reports:
      codequality: hadolint-report.json
    when: always

使用するタイミング: 自動化されたセキュリティゲート、プルリクエストチェック、デプロイメント検証。

3. 構成のカスタマイズ

.hadolint.yaml を作成してルールをカスタマイズします。

# .hadolint.yaml
failure-threshold: warning
ignored:
  - DL3008  # 許可: バージョンが固定されていない apt-get パッケージ (最初にリスクを評価)
  - DL3059  # 許可: 複数の RUN 命令

trustedRegistries:
  - docker.io/library  # 公式 Docker Hub イメージ
  - gcr.io/distroless  # Google distroless イメージ
  - registry.access.redhat.com  # Red Hat レジストリ

override:
  error:
    - DL3001  # 強制: バージョンピンなしで yum/dnf/zypper を使用しないでください
  warning:
    - DL3015  # 警告: apt-get で --no-install-recommends を使用してください
  info:
    - DL3059  # 情報: 複数の RUN 命令はレイヤーキャッシュを削減します

label-schema:
  maintainer: text
  org.opencontainers.image.vendor: text
  org.opencontainers.image.version: semver

assets/ にバンドルされているテンプレートを使用します。

  • assets/hadolint-strict.yaml - 厳格なセキュリティ強制 (CRITICAL/HIGH のみ)
  • assets/hadolint-balanced.yaml - バランスの取れた検証 (推奨)
  • assets/hadolint-permissive.yaml - レガシー Dockerfile 用の寛容な設定

使用するタイミング: 誤検知の削減、組織標準、レガシー Dockerfile の移行。

4. セキュリティ重視の検証

重要なセキュリティルールを強制します。

# セキュリティ問題 (エラー重大度) のみで失敗
hadolint --failure-threshold error Dockerfile

# 特定のセキュリティルールを確認
hadolint --trusted-registry docker.io/library Dockerfile

# プロジェクト内のすべての Dockerfile をスキャン
find . -name "Dockerfile*" -exec hadolint {} \;

# エラーのみを含むセキュリティレポートを生成
hadolint -f json Dockerfile | jq '.[] | select(.level == "error")'

重要なセキュリティルール:

  • DL3000: 絶対 WORKDIR を使用する (ディレクトリトラバーサルを防止)
  • DL3001: パッケージマネージャーには常にバージョンピンを使用する
  • DL3002: Dockerfile で root USER に切り替えない
  • DL3020: ADD の代わりに COPY を使用する (任意の URL フェッチを防止)
  • DL3025: CMD/ENTRYPOINT に JSON 表記を使用する (シェルインジェクションを防止)

CIS マッピングを含む完全なセキュリティルールカタログについては、references/security_rules.md を参照してください。

5. マルチステージビルドの検証

複雑なマルチステージ Dockerfile をスキャンします。

# すべてのステージを検証
hadolint Dockerfile

# ステージ固有の検証 (カスタムスクリプトを使用)
./scripts/hadolint_multistage.py Dockerfile

一般的なマルチステージの問題:

  • ビルドステージとランタイムステージで同じユーザーを使用する
  • 不要なビルドツールを本番イメージにコピーする
  • 最終ステージでのセキュリティ強化の欠如
  • ビルドステージに存在するシークレットがランタイムに伝播する

使用するタイミング: 複雑なビルド、セキュリティ強化されたイメージ、本番コンテナ化。

6. Pre-Commit Hook の統合

安全でない Dockerfile がコミットされるのを防ぎます。

# バンドルされたスクリプトを使用して pre-commit hook をインストール
./scripts/install_precommit.sh

# または手動で ho
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Dockerfile Security Linting with Hadolint

Overview

Hadolint is a Dockerfile linter that validates container build files against security best practices and the CIS Docker Benchmark. It analyzes Dockerfile instructions to identify misconfigurations, anti-patterns, and security vulnerabilities before images are built and deployed.

Hadolint integrates ShellCheck to validate RUN instructions, ensuring shell commands follow security best practices. With 100+ built-in rules mapped to CIS Docker Benchmark controls, Hadolint provides comprehensive security validation for container images.

Quick Start

Install Hadolint

# macOS via Homebrew
brew install hadolint

# Linux via binary
wget -O /usr/local/bin/hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64
chmod +x /usr/local/bin/hadolint

# Via Docker
docker pull hadolint/hadolint

Scan Dockerfile

# Scan Dockerfile in current directory
hadolint Dockerfile

# Scan with specific Dockerfile path
hadolint path/to/Dockerfile

# Using Docker
docker run --rm -i hadolint/hadolint < Dockerfile

Generate Report

# JSON output for automation
hadolint -f json Dockerfile > hadolint-report.json

# GitLab Code Quality format
hadolint -f gitlab_codeclimate Dockerfile > hadolint-codeclimate.json

# Checkstyle format for CI integration
hadolint -f checkstyle Dockerfile > hadolint-checkstyle.xml

Core Workflows

1. Local Development Scanning

Validate Dockerfiles during development:

# Basic scan with colored output
hadolint Dockerfile

# Scan with specific severity threshold
hadolint --failure-threshold error Dockerfile

# Show only warnings and errors
hadolint --no-color --format tty Dockerfile | grep -E "^(warning|error)"

# Verbose output with rule IDs
hadolint -t style -t warning -t error Dockerfile

Output Format:

Dockerfile:3 DL3008 warning: Pin versions in apt get install
Dockerfile:7 DL3025 error: Use JSON notation for CMD and ENTRYPOINT
Dockerfile:12 DL3059 info: Multiple RUN instructions detected

When to use: Developer workstation, pre-commit validation, iterative Dockerfile development.

2. CI/CD Pipeline Integration

Automate Dockerfile validation in build pipelines:

GitHub Actions

name: Hadolint
on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Hadolint Dockerfile
        uses: hadolint/hadolint-action@v3.1.0
        with:
          dockerfile: Dockerfile
          failure-threshold: warning
          format: sarif
          output-file: hadolint.sarif

      - name: Upload SARIF to GitHub Security
        if: always()
        uses: github/codeql-action/upload-sarif@v2
        with:
          sarif_file: hadolint.sarif

GitLab CI

hadolint:
  image: hadolint/hadolint:latest-debian
  stage: lint
  script:
    - hadolint -f gitlab_codeclimate Dockerfile > hadolint-report.json
  artifacts:
    reports:
      codequality: hadolint-report.json
    when: always

When to use: Automated security gates, pull request checks, deployment validation.

3. Configuration Customization

Create .hadolint.yaml to customize rules:

# .hadolint.yaml
failure-threshold: warning
ignored:
  - DL3008  # Allow unpinned apt-get packages (assess risk first)
  - DL3059  # Allow multiple RUN instructions

trustedRegistries:
  - docker.io/library  # Official Docker Hub images
  - gcr.io/distroless  # Google distroless images
  - registry.access.redhat.com  # Red Hat registry

override:
  error:
    - DL3001  # Enforce: never use yum/dnf/zypper without version pins
  warning:
    - DL3015  # Warn: use --no-install-recommends with apt-get
  info:
    - DL3059  # Info: multiple RUN instructions reduce layer caching

label-schema:
  maintainer: text
  org.opencontainers.image.vendor: text
  org.opencontainers.image.version: semver

Use bundled templates in assets/:

  • assets/hadolint-strict.yaml - Strict security enforcement (CRITICAL/HIGH only)
  • assets/hadolint-balanced.yaml - Balanced validation (recommended)
  • assets/hadolint-permissive.yaml - Permissive for legacy Dockerfiles

When to use: Reducing false positives, organizational standards, legacy Dockerfile migration.

4. Security-Focused Validation

Enforce critical security rules:

# Only fail on security issues (error severity)
hadolint --failure-threshold error Dockerfile

# Check specific security rules
hadolint --trusted-registry docker.io/library Dockerfile

# Scan all Dockerfiles in project
find . -name "Dockerfile*" -exec hadolint {} \;

# Generate security report with only errors
hadolint -f json Dockerfile | jq '.[] | select(.level == "error")'

Critical Security Rules:

  • DL3000: Use absolute WORKDIR (prevents directory traversal)
  • DL3001: Always use version pinning for package managers
  • DL3002: Never switch to root USER in Dockerfile
  • DL3020: Use COPY instead of ADD (prevents arbitrary URL fetching)
  • DL3025: Use JSON notation for CMD/ENTRYPOINT (prevents shell injection)

See references/security_rules.md for complete security rule catalog with CIS mappings.

5. Multi-Stage Build Validation

Scan complex multi-stage Dockerfiles:

# Validate all stages
hadolint Dockerfile

# Stage-specific validation (use custom script)
./scripts/hadolint_multistage.py Dockerfile

Common Multi-Stage Issues:

  • Using same user across build and runtime stages
  • Copying unnecessary build tools to production image
  • Missing security hardening in final stage
  • Secrets present in build stage propagating to runtime

When to use: Complex builds, security-hardened images, production containerization.

6. Pre-Commit Hook Integration

Prevent insecure Dockerfiles from being committed:

# Install pre-commit hook using bundled script
./scripts/install_precommit.sh

# Or manually create hook
cat << 'EOF' > .git/hooks/pre-commit
#!/bin/bash
for dockerfile in $(git diff --cached --name-only | grep -E 'Dockerfile'); do
  hadolint --failure-threshold warning "$dockerfile" || exit 1
done
EOF

chmod +x .git/hooks/pre-commit

When to use: Developer workstations, team onboarding, mandatory security controls.

Security Considerations

Sensitive Data Handling

  • Secret Detection: Hadolint flags hardcoded secrets in ENV, ARG, LABEL instructions
  • Build Secrets: Use Docker BuildKit secrets (RUN --mount=type=secret) instead of ARG for credentials
  • Multi-Stage Security: Ensure secrets in build stages don't leak to final image
  • Image Scanning: Hadolint validates Dockerfile - combine with image scanning (Trivy, Grype) for runtime security

Access Control

  • CI/CD Permissions: Hadolint scans require read access to Dockerfile and build context
  • Report Storage: Treat scan reports as internal documentation - may reveal security practices
  • Trusted Registries: Configure trustedRegistries to enforce approved base image sources

Audit Logging

Log the following for compliance and security auditing:

  • Scan execution timestamps and Dockerfile paths
  • Rule violations by severity (error, warning, info)
  • Suppressed rules and justifications
  • Base image registry validation results
  • Remediation actions and timeline

Compliance Requirements

  • CIS Docker Benchmark 1.6: Hadolint rules map to CIS controls (see references/cis_mapping.md)
    • 4.1: Create a user for the container (DL3002)
    • 4.6: Add HEALTHCHECK instruction (DL3025)
    • 4.7: Do not use update alone in Dockerfile (DL3009)
    • 4.9: Use COPY instead of ADD (DL3020)
  • OWASP Docker Security: Validates against OWASP container security best practices
  • NIST SP 800-190: Application container security guidance

Bundled Resources

Scripts (scripts/)

  • hadolint_scan.py - Comprehensive scanning with multiple Dockerfiles and output formats
  • hadolint_multistage.py - Multi-stage Dockerfile analysis with stage-specific validation
  • install_precommit.sh - Automated pre-commit hook installation
  • ci_integration.sh - CI/CD integration examples for multiple platforms

References (references/)

  • security_rules.md - Complete Hadolint security rules with CIS Benchmark mappings
  • cis_mapping.md - Detailed CIS Docker Benchmark control mapping
  • remediation_guide.md - Rule-by-rule remediation guidance with secure examples
  • shellcheck_integration.md - ShellCheck rules for RUN instruction validation

Assets (assets/)

  • hadolint-strict.yaml - Strict security configuration
  • hadolint-balanced.yaml - Production-ready configuration (recommended)
  • hadolint-permissive.yaml - Legacy Dockerfile migration configuration
  • github-actions.yml - Complete GitHub Actions workflow
  • gitlab-ci.yml - Complete GitLab CI pipeline
  • precommit-config.yaml - Pre-commit framework configuration

Common Patterns

Pattern 1: Initial Dockerfile Security Audit

First-time security assessment:

# 1. Find all Dockerfiles
find . -type f -name "Dockerfile*" > dockerfile-list.txt

# 2. Scan all Dockerfiles with JSON output
mkdir -p security-reports
while read dockerfile; do
  output_file="security-reports/$(echo $dockerfile | tr '/' '_').json"
  hadolint -f json "$dockerfile" > "$output_file" 2>&1
done < dockerfile-list.txt

# 3. Generate summary report
./scripts/hadolint_scan.py --input-dir . --output summary-report.html

# 4. Review critical/high findings
cat security-reports/*.json | jq '.[] | select(.level == "error")' > critical-findings.json

Pattern 2: Progressive Remediation

Gradual security hardening:

# Phase 1: Baseline (don't fail builds yet)
hadolint --failure-threshold none -f json Dockerfile > baseline.json

# Phase 2: Fix critical issues (fail on errors only)
hadolint --failure-threshold error Dockerfile

# Phase 3: Address warnings
hadolint --failure-threshold warning Dockerfile

# Phase 4: Full compliance (including style/info)
hadolint Dockerfile

Pattern 3: Security-Hardened Production Image

Build security-first container image:

# Example secure Dockerfile following Hadolint best practices

# Use specific base image version from trusted registry
FROM docker.io/library/node:18.19.0-alpine3.19

# Install packages with version pinning and cleanup
RUN apk add --no-cache \
    dumb-init=1.2.5-r2 \
    && rm -rf /var/cache/apk/*

# Create non-root user
RUN addgroup -g 1001 -S appuser && \
    adduser -S -u 1001 -G appuser appuser

# Set working directory
WORKDIR /app

# Copy application files (use COPY not ADD)
COPY --chown=appuser:appuser package*.json ./
COPY --chown=appuser:appuser . .

# Install dependencies
RUN npm ci --only=production && \
    npm cache clean --force

# Switch to non-root user
USER appuser

# Expose port (document only, not security control)
EXPOSE 3000

# Add healthcheck
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node healthcheck.js || exit 1

# Use JSON notation for entrypoint/cmd
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["node", "server.js"]

Validate with Hadolint:

hadolint Dockerfile  # Should pass with no errors

Pattern 4: CI/CD with Automated Remediation Suggestions

Provide actionable feedback in pull requests:

# In CI pipeline
hadolint -f json Dockerfile > hadolint.json

# Generate remediation suggestions
./scripts/hadolint_scan.py \
  --input hadolint.json \
  --format markdown \
  --output pr-comment.md

# Post to PR comment (using gh CLI)
gh pr comment --body-file pr-comment.md

Integration Points

CI/CD Integration

  • GitHub Actions: Native hadolint-action with SARIF support for Security tab
  • GitLab CI: GitLab Code Quality format integration
  • Jenkins: Checkstyle format for Jenkins Warnings plugin
  • CircleCI: Docker-based executor with artifact retention
  • Azure Pipelines: Task integration with results publishing

Security Tools Ecosystem

  • Image Scanning: Combine with Trivy, Grype, Clair for runtime vulnerability scanning
  • Secret Scanning: Integrate with Gitleaks, TruffleHog for comprehensive secret detection
  • IaC Security: Chain with Checkov for Kubernetes/Terraform validation
  • SBOM Generation: Export findings alongside Syft/Trivy SBOM reports
  • Security Dashboards: Export JSON to Grafana, Kibana, Datadog for centralized monitoring

SDLC Integration

  • Development: Pre-commit hooks provide immediate feedback
  • Code Review: PR checks prevent insecure Dockerfiles from merging
  • Testing: Scan test environment Dockerfiles
  • Staging: Validation gate before production promotion
  • Production: Periodic audits of deployed container configurations

Troubleshooting

Issue: Too Many False Positives

Symptoms: Legitimate patterns flagged (legacy Dockerfiles, specific use cases)

Solution:

# Create .hadolint.yaml
ignored:
  - DL3059  # Multiple RUN instructions (valid for complex builds)

# Or use inline ignores
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y curl

Consult references/remediation_guide.md for rule-specific guidance.

Issue: Base Image Registry Not Trusted

Symptoms: Error about untrusted registry even for legitimate images

Solution:

# Add to .hadolint.yaml
trustedRegistries:
  - mycompany.azurecr.io
  - gcr.io/my-project
  - docker.io/library

Issue: ShellCheck Warnings in RUN Instructions

Symptoms: SC2086, SC2046 warnings from ShellCheck integration

Solution:

# Bad: Unquoted variables
RUN echo $MY_VAR > file.txt

# Good: Quoted variables
RUN echo "$MY_VAR" > file.txt

# Or disable specific ShellCheck rule
# hadolint ignore=DL4006
RUN echo $MY_VAR > file.txt

See references/shellcheck_integration.md for complete ShellCheck guidance.

Issue: Multi-Stage Build Not Recognized

Symptoms: Errors about missing USER instruction despite proper multi-stage setup

Solution:

# Ensure each stage has appropriate USER
FROM node:18 AS builder
# Build operations...

FROM node:18-alpine AS runtime
USER node  # Add USER in final stage
CMD ["node", "app.js"]

Issue: CI Pipeline Failing on Warnings

Symptoms: Build fails on low-severity issues

Solution:

# Adjust failure threshold in CI
hadolint --failure-threshold error Dockerfile

# Or configure per-environment
if [ "$CI_ENVIRONMENT" == "production" ]; then
  hadolint --failure-threshold warning Dockerfile
else
  hadolint --failure-threshold error Dockerfile
fi

Advanced Configuration

Custom Rule Severity Override

# .hadolint.yaml
override:
  error:
    - DL3001  # Package versioning is critical
    - DL3020  # COPY vs ADD is security-critical
  warning:
    - DL3059  # Multiple RUN is warning, not info
  info:
    - DL3008  # Downgrade apt-get pinning to info for dev images

Inline Suppression

# Suppress single rule for one instruction
# hadolint ignore=DL3018
RUN apk add --no-cache curl

# Suppress multiple rules
# hadolint ignore=DL3003,DL3009
WORKDIR /tmp
RUN apt-get update && apt-get install -y wget

# Global suppression (use sparingly)
# hadolint global ignore=DL3059

Trusted Registry Enforcement

# .hadolint.yaml
trustedRegistries:
  - docker.io/library      # Official images only
  - gcr.io/distroless      # Google distroless
  - cgr.dev/chainguard     # Chainguard images

# This will error on:
# FROM nginx:latest                    ❌ (docker.io/nginx)
# FROM docker.io/library/nginx:latest  ✅ (trusted)

Label Schema Validation

# .hadolint.yaml
label-schema:
  maintainer: text
  org.opencontainers.image.created: rfc3339
  org.opencontainers.image.version: semver
  org.opencontainers.image.vendor: text

Ensures Dockerfile LABELs conform to OCI image specification.

References

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。