jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ Docker Development

docker-development

Dockerを使ったアプリケーション開発で、設定ファイルの最適

⏱ ライブラリ調査+組込 半日 → 1時間

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

Docker and container development agent skill and plugin for Dockerfile optimization, docker-compose orchestration, multi-stage builds, and container security hardening. Use when: user wants to optimize a Dockerfile, create or improve docker-compose configurations, implement multi-stage builds, audit container security, reduce image size, or follow container best practices. Covers build performance, layer caching, secret management, and production-ready container patterns.

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

一言でいうと

Dockerを使ったアプリケーション開発で、設定ファイルの最適

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

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して docker-development.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → docker-development フォルダができる
  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-17
取得日時
2026-05-18
同梱ファイル
5

💬 こう話しかけるだけ — サンプルプロンプト

  • Docker Development を使って、最小構成のサンプルコードを示して
  • Docker Development の主な使い方と注意点を教えて
  • Docker Development を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

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

Docker開発

より小さなイメージ。より速いビルド。安全なコンテナ。推測は不要です。

肥大化したDockerfileを本番環境レベルのコンテナに変える、独自のDockerワークフローです。最適化、マルチステージビルド、Composeオーケストレーション、セキュリティ強化を網羅しています。

これはDockerのチュートリアルではなく、時間、スペース、攻撃対象領域を無駄にしないコンテナを構築するための具体的な決定事項のセットです。


スラッシュコマンド

コマンド 内容
/docker:optimize Dockerfileを分析し、サイズ、速度、レイヤーキャッシュのために最適化します
/docker:compose ベストプラクティスを用いてdocker-compose.ymlを生成または改善します
/docker:security Dockerfileまたは実行中のコンテナのセキュリティ問題を監査します

このスキルが有効になる場合

ユーザーからの以下のパターンを認識します。

  • 「このDockerfileを最適化してください」
  • 「私のDockerビルドが遅いです」
  • 「このプロジェクトのdocker-composeを作成してください」
  • 「このDockerfileは安全ですか?」
  • 「Dockerイメージのサイズを減らしてください」
  • 「マルチステージビルドを設定してください」
  • 「[言語/フレームワーク]向けのDockerベストプラクティス」
  • Dockerfile、docker-compose、コンテナ、イメージサイズ、ビルドキャッシュ、Dockerセキュリティを含むあらゆるリクエスト

ユーザーがDockerfileを持っている場合、または何かをコンテナ化したい場合 → このスキルが適用されます。


ワークフロー

/docker:optimize — Dockerfileの最適化

  1. 現在の状態を分析

    • Dockerfileを読み取ります
    • ベースイメージとそのサイズを特定します
    • レイヤー数を数えます(各RUN/COPY/ADD = 1レイヤー)
    • 一般的なアンチパターンをチェックします
  2. 最適化チェックリストを適用

    ベースイメージ
    ├── 本番環境では特定のタグを使用し、決して:latestを使用しない
    ├── slim/alpineバリアントを優先する (debian-slim > ubuntu > debian)
    ├── CIでの再現性のためにダイジェストを固定する: image@sha256:...
    └── ベースをランタイムのニーズに合わせる (コンパイル済みバイナリにpython:3.12を使用しない)
    
    レイヤーの最適化
    ├── 関連するRUNコマンドを&& \で結合する
    ├── レイヤーの順序: 変更が少ないものを最初に (ソースコードの前に依存関係)
    ├── 同じRUNレイヤーでパッケージマネージャーのキャッシュをクリーンアップする
    ├── 不要なファイルを.dockerignoreで除外する
    └── ビルド依存関係とランタイム依存関係を分離する
    
    ビルドキャッシュ
    ├── ソースコードの前に依存関係ファイルをCOPYする (package.json, requirements.txt, go.mod)
    ├── コードコピーとは別のレイヤーで依存関係をインストールする
    ├── BuildKitキャッシュマウントを使用する: --mount=type=cache,target=/root/.cache
    └── 依存関係のインストール前にCOPY . .を避ける
    
    マルチステージビルド
    ├── ステージ1: ビルド (フルSDK、ビルドツール、開発依存関係)
    ├── ステージ2: ランタイム (最小限のベース、本番アーティファクトのみ)
    ├── --from=builderで必要なものだけをCOPYする
    └── 最終イメージにはビルドツール、ソースコード、開発依存関係を含まない
  3. 最適化されたDockerfileを生成

    • 関連するすべての最適化を適用します
    • 各決定を説明するインラインコメントを追加します
    • 推定されるサイズ削減を報告します
  4. 検証

    python3 scripts/dockerfile_analyzer.py Dockerfile

/docker:compose — Docker Composeの設定

  1. サービスを特定

    • アプリケーション (web, API, worker)
    • データベース (postgres, mysql, redis, mongo)
    • キャッシュ (redis, memcached)
    • キュー (rabbitmq, kafka)
    • リバースプロキシ (nginx, traefik, caddy)
  2. Composeのベストプラクティスを適用

    サービス
    ├── condition: service_healthy付きのdepends_onを使用する
    ├── すべてのサービスにヘルスチェックを追加する
    ├── リソース制限を設定する (mem_limit, cpus)
    ├── 永続データには名前付きボリュームを使用する
    └── イメージバージョンを固定する
    
    ネットワーク
    ├── 明示的なネットワークを作成する (デフォルトに依存しない)
    ├── フロントエンドとバックエンドのネットワークを分離する
    ├── 外部アクセスが必要なポートのみを公開する
    └── バックエンド専用ネットワークにはinternal: trueを使用する
    
    環境
    ├── シークレットにはenv_fileを使用し、インライン環境変数を使用しない
    ├── .envファイルをコミットしない (gitignoreに追加する)
    ├── 変数置換を使用する: ${VAR:-default}
    └── 必要なすべての環境変数を文書化する
    
    開発 vs 本番
    ├── composeプロファイルまたはオーバーライドファイルを使用する
    ├── 開発: ホットリロード用のバインドマウント、デバッグポートを公開
    ├── 本番: 名前付きボリューム、デバッグポートなし、restart: unless-stopped
    └── 開発専用設定にはdocker-compose.override.ymlを使用する
  3. Composeファイルを生成

    • ヘルスチェック、ネットワーク、ボリュームを含むdocker-compose.ymlを出力します
    • 必要なすべての変数を文書化した.env.exampleを生成します
    • 開発/本番プロファイルのアノテーションを追加します

/docker:security — コンテナセキュリティ監査

  1. Dockerfile監査

    チェック 重大度 修正
    rootで実行 致命的 ユーザー作成後にUSER nonrootを追加
    :latestタグの使用 特定のバージョンに固定
    ENV/ARG内のシークレット 致命的 BuildKitシークレットを使用: --mount=type=secret
    広範なグロブでのCOPY 特定のパスを使用し、.dockerignoreを追加
    不要なEXPOSE アプリが使用するポートのみを公開
    HEALTHCHECKなし 適切な間隔でHEALTHCHECKを追加
    特権命令 --privilegedを避け、機能を削除
    パッケージマネージャーキャッシュの保持 同じRUNレイヤーでクリーンアップ
  2. ランタイムセキュリティチェック

    チェック 重大度 修正
    コンテナがrootで実行 致命的 DockerfileまたはComposeでユーザーを設定
    書き込み可能なルートファイルシステム Composeでread_only: trueを使用
    すべての機能が保持されている すべてを削除し、必要なもののみを追加: cap_drop: [ALL]
    リソース制限なし mem_limitcpusを設定
    ホストネットワークモード ブリッジまたはカスタムネットワークを使用
    機密マウント 致命的 本番環境で/etc、/var/run/docker.sockをマウントしない
    ログドライバーが設定されていない サイズ制限付きでlogging:を設定
  3. セキュリティレポートを生成

    セキュリティ監査 — [Dockerfile/イメージ名]
    日付: [タイムスタンプ]
    
    致命的: [カウント]
    高:     [カウント]
    中:     [カウント]
    低:      [カウント]
    
    [修正推奨事項を含む詳細な調査結果]

ツール

scripts/dockerfile_analyzer.py

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Docker Development

Smaller images. Faster builds. Secure containers. No guesswork.

Opinionated Docker workflow that turns bloated Dockerfiles into production-grade containers. Covers optimization, multi-stage builds, compose orchestration, and security hardening.

Not a Docker tutorial — a set of concrete decisions about how to build containers that don't waste time, space, or attack surface.


Slash Commands

Command What it does
/docker:optimize Analyze and optimize a Dockerfile for size, speed, and layer caching
/docker:compose Generate or improve docker-compose.yml with best practices
/docker:security Audit a Dockerfile or running container for security issues

When This Skill Activates

Recognize these patterns from the user:

  • "Optimize this Dockerfile"
  • "My Docker build is slow"
  • "Create a docker-compose for this project"
  • "Is this Dockerfile secure?"
  • "Reduce my Docker image size"
  • "Set up multi-stage builds"
  • "Docker best practices for [language/framework]"
  • Any request involving: Dockerfile, docker-compose, container, image size, build cache, Docker security

If the user has a Dockerfile or wants to containerize something → this skill applies.


Workflow

/docker:optimize — Dockerfile Optimization

  1. Analyze current state

    • Read the Dockerfile
    • Identify base image and its size
    • Count layers (each RUN/COPY/ADD = 1 layer)
    • Check for common anti-patterns
  2. Apply optimization checklist

    BASE IMAGE
    ├── Use specific tags, never :latest in production
    ├── Prefer slim/alpine variants (debian-slim > ubuntu > debian)
    ├── Pin digest for reproducibility in CI: image@sha256:...
    └── Match base to runtime needs (don't use python:3.12 for a compiled binary)
    
    LAYER OPTIMIZATION
    ├── Combine related RUN commands with && \
    ├── Order layers: least-changing first (deps before source code)
    ├── Clean package manager cache in the same RUN layer
    ├── Use .dockerignore to exclude unnecessary files
    └── Separate build deps from runtime deps
    
    BUILD CACHE
    ├── COPY dependency files before source code (package.json, requirements.txt, go.mod)
    ├── Install deps in a separate layer from code copy
    ├── Use BuildKit cache mounts: --mount=type=cache,target=/root/.cache
    └── Avoid COPY . . before dependency installation
    
    MULTI-STAGE BUILDS
    ├── Stage 1: build (full SDK, build tools, dev deps)
    ├── Stage 2: runtime (minimal base, only production artifacts)
    ├── COPY --from=builder only what's needed
    └── Final image should have NO build tools, NO source code, NO dev deps
  3. Generate optimized Dockerfile

    • Apply all relevant optimizations
    • Add inline comments explaining each decision
    • Report estimated size reduction
  4. Validate

    python3 scripts/dockerfile_analyzer.py Dockerfile

/docker:compose — Docker Compose Configuration

  1. Identify services

    • Application (web, API, worker)
    • Database (postgres, mysql, redis, mongo)
    • Cache (redis, memcached)
    • Queue (rabbitmq, kafka)
    • Reverse proxy (nginx, traefik, caddy)
  2. Apply compose best practices

    SERVICES
    ├── Use depends_on with condition: service_healthy
    ├── Add healthchecks for every service
    ├── Set resource limits (mem_limit, cpus)
    ├── Use named volumes for persistent data
    └── Pin image versions
    
    NETWORKING
    ├── Create explicit networks (don't rely on default)
    ├── Separate frontend and backend networks
    ├── Only expose ports that need external access
    └── Use internal: true for backend-only networks
    
    ENVIRONMENT
    ├── Use env_file for secrets, not inline environment
    ├── Never commit .env files (add to .gitignore)
    ├── Use variable substitution: ${VAR:-default}
    └── Document all required env vars
    
    DEVELOPMENT vs PRODUCTION
    ├── Use compose profiles or override files
    ├── Dev: bind mounts for hot reload, debug ports exposed
    ├── Prod: named volumes, no debug ports, restart: unless-stopped
    └── docker-compose.override.yml for dev-only config
  3. Generate compose file

    • Output docker-compose.yml with healthchecks, networks, volumes
    • Generate .env.example with all required variables documented
    • Add dev/prod profile annotations

/docker:security — Container Security Audit

  1. Dockerfile audit

    Check Severity Fix
    Running as root Critical Add USER nonroot after creating user
    Using :latest tag High Pin to specific version
    Secrets in ENV/ARG Critical Use BuildKit secrets: --mount=type=secret
    COPY with broad glob Medium Use specific paths, add .dockerignore
    Unnecessary EXPOSE Low Only expose ports the app uses
    No HEALTHCHECK Medium Add HEALTHCHECK with appropriate interval
    Privileged instructions High Avoid --privileged, drop capabilities
    Package manager cache retained Low Clean in same RUN layer
  2. Runtime security checks

    Check Severity Fix
    Container running as root Critical Set user in Dockerfile or compose
    Writable root filesystem Medium Use read_only: true in compose
    All capabilities retained High Drop all, add only needed: cap_drop: [ALL]
    No resource limits Medium Set mem_limit and cpus
    Host network mode High Use bridge or custom network
    Sensitive mounts Critical Never mount /etc, /var/run/docker.sock in prod
    No log driver configured Low Set logging: with size limits
  3. Generate security report

    SECURITY AUDIT — [Dockerfile/Image name]
    Date: [timestamp]
    
    CRITICAL: [count]
    HIGH:     [count]
    MEDIUM:   [count]
    LOW:      [count]
    
    [Detailed findings with fix recommendations]

Tooling

scripts/dockerfile_analyzer.py

CLI utility for static analysis of Dockerfiles.

Features:

  • Layer count and optimization suggestions
  • Base image analysis with size estimates
  • Anti-pattern detection (15+ rules)
  • Security issue flagging
  • Multi-stage build detection and validation
  • JSON and text output

Usage:

# Analyze a Dockerfile
python3 scripts/dockerfile_analyzer.py Dockerfile

# JSON output
python3 scripts/dockerfile_analyzer.py Dockerfile --output json

# Analyze with security focus
python3 scripts/dockerfile_analyzer.py Dockerfile --security

# Check a specific directory
python3 scripts/dockerfile_analyzer.py path/to/Dockerfile

scripts/compose_validator.py

CLI utility for validating docker-compose files.

Features:

  • Service dependency validation
  • Healthcheck presence detection
  • Network configuration analysis
  • Volume mount validation
  • Environment variable audit
  • Port conflict detection
  • Best practice scoring

Usage:

# Validate a compose file
python3 scripts/compose_validator.py docker-compose.yml

# JSON output
python3 scripts/compose_validator.py docker-compose.yml --output json

# Strict mode (fail on warnings)
python3 scripts/compose_validator.py docker-compose.yml --strict

Multi-Stage Build Patterns

Pattern 1: Compiled Language (Go, Rust, C++)

# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/server ./cmd/server

# Runtime stage
FROM gcr.io/distroless/static-debian12
COPY --from=builder /app/server /server
USER nonroot:nonroot
ENTRYPOINT ["/server"]

Pattern 2: Node.js / TypeScript

# Dependencies stage
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production=false

# Build stage
FROM deps AS builder
COPY . .
RUN npm run build

# Runtime stage
FROM node:20-alpine
WORKDIR /app
RUN addgroup -g 1001 -S appgroup && adduser -S appuser -u 1001
COPY --from=builder /app/dist ./dist
COPY --from=deps /app/node_modules ./node_modules
COPY package.json ./
USER appuser
EXPOSE 3000
CMD ["node", "dist/index.js"]

Pattern 3: Python

# Build stage
FROM python:3.12-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt

# Runtime stage
FROM python:3.12-slim
WORKDIR /app
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
COPY --from=builder /install /usr/local
COPY . .
USER appuser
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Base Image Decision Tree

Is it a compiled binary (Go, Rust, C)?
├── Yes → distroless/static or scratch
└── No
    ├── Need a shell for debugging?
    │   ├── Yes → alpine variant (e.g., node:20-alpine)
    │   └── No → distroless variant
    ├── Need glibc (not musl)?
    │   ├── Yes → slim variant (e.g., python:3.12-slim)
    │   └── No → alpine variant
    └── Need specific OS packages?
        ├── Many → debian-slim
        └── Few → alpine + apk add

Proactive Triggers

Flag these without being asked:

  • Dockerfile uses :latest → Suggest pinning to a specific version tag.
  • No .dockerignore → Create one. At minimum: .git, node_modules, __pycache__, .env.
  • COPY . . before dependency install → Cache bust. Reorder to install deps first.
  • Running as root → Add USER instruction. No exceptions for production.
  • Secrets in ENV or ARG → Use BuildKit secret mounts. Never bake secrets into layers.
  • Image over 1GB → Multi-stage build required. No reason for a production image this large.
  • No healthcheck → Add one. Orchestrators (Compose, K8s) need it for proper lifecycle management.
  • apt-get without cleanup in same layerrm -rf /var/lib/apt/lists/* in the same RUN.

Installation

One-liner (any tool)

git clone https://github.com/alirezarezvani/claude-skills.git
cp -r claude-skills/engineering/docker-development ~/.claude/skills/

Multi-tool install

./scripts/convert.sh --skill docker-development --tool codex|gemini|cursor|windsurf|openclaw

OpenClaw

clawhub install cs-docker-development

Related Skills

  • senior-devops — Broader DevOps scope (CI/CD, IaC, monitoring). Complementary — use docker-development for container-specific work, senior-devops for pipeline and infrastructure.
  • senior-security — Application security. Complementary — docker-development covers container security, senior-security covers application-level threats.
  • autoresearch-agent — Can optimize Docker build times or image sizes as measurable experiments.
  • ci-cd-pipeline-builder — Pipeline construction. Complementary — docker-development builds the containers, ci-cd-pipeline-builder deploys them.

同梱ファイル

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