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

docker-containerization

Dockerを使ってアプリケーションをコンテナ化し、Dockerfileやdocker-composeの設定を作成、Kubernetesなどのプラットフォームへデプロイする際に、開発・本番環境やCI/CDパイプライン構築を支援するSkill。

📜 元の英語説明(参考)

This skill should be used when containerizing applications with Docker, creating Dockerfiles, docker-compose configurations, or deploying containers to various platforms. Ideal for Next.js, React, Node.js applications requiring containerization for development, production, or CI/CD pipelines. Use this skill when users need Docker configurations, multi-stage builds, container orchestration, or deployment to Kubernetes, ECS, Cloud Run, etc.

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

一言でいうと

Dockerを使ってアプリケーションをコンテナ化し、Dockerfileやdocker-composeの設定を作成、Kubernetesなどのプラットフォームへデプロイする際に、開発・本番環境やCI/CDパイプライン構築を支援するSkill。

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

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

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

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

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

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

📖 Skill本文(日本語訳)

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

Dockerコンテナ化スキル

概要

最新のWebアプリケーション、特にNext.jsおよびNode.jsプロジェクト向けに、本番環境に対応したDocker構成を生成します。このスキルは、Dockerfile、docker-composeの設定、コンテナ管理用のbashスクリプト、およびさまざまなオーケストレーションプラットフォーム向けの包括的なデプロイメントガイドを提供します。

主要な機能

1. Dockerfileの生成

さまざまな環境向けに最適化されたDockerfileを作成します。

本番環境 (assets/Dockerfile.production):

  • イメージサイズを85%削減するマルチステージビルド
  • Alpine Linuxベース(最終イメージは約180MB)
  • セキュリティのための非rootユーザー実行
  • ヘルスチェックとリソース制限

開発環境 (assets/Dockerfile.development):

  • ホットリロードのサポート
  • すべての開発用依存関係が含まれる
  • ライブコード更新のためのボリュームマウント

Nginx Static (assets/Dockerfile.nginx):

  • 静的エクスポートの最適化
  • Nginxリバースプロキシが含まれる
  • 可能な限り最小のフットプリント

2. Docker Composeの設定

assets/docker-compose.ymlを使用したマルチコンテナオーケストレーション:

  • 開発および本番環境サービス
  • ネットワークとボリュームの管理
  • ヘルスチェックとロギング
  • 再起動ポリシー

3. コンテナ管理用のBashスクリプト

docker-build.sh - 包括的なオプションでイメージをビルドします:

./docker-build.sh -e prod -t v1.0.0
./docker-build.sh -n my-app --no-cache --platform linux/amd64

docker-run.sh - 完全な構成でコンテナを実行します:

./docker-run.sh -i my-app -t v1.0.0 -d
./docker-run.sh -p 8080:3000 --env-file .env.production

docker-push.sh - レジストリ(Docker Hub、ECR、GCR、ACR)にプッシュします:

./docker-push.sh -n my-app -t v1.0.0 --repo username/my-app
./docker-push.sh -r gcr.io/project --repo my-app --also-tag stable

docker-cleanup.sh - ディスク容量を解放します:

./docker-cleanup.sh --all --dry-run  # クリーンアップのプレビュー
./docker-cleanup.sh --containers --images  # 特定のリソースをクリーンアップ

4. 構成ファイル

  • .dockerignore: 不要なファイル(node_modules、.git、logs)を除外します
  • nginx.conf: 圧縮、キャッシュ、セキュリティヘッダーを備えた本番環境対応のNginx構成

5. 参照ドキュメント

docker-best-practices.mdの内容:

  • マルチステージビルドの説明
  • イメージ最適化テクニック(50〜85%のサイズ削減)
  • セキュリティのベストプラクティス(非rootユーザー、脆弱性スキャン)
  • パフォーマンスの最適化
  • ヘルスチェックとロギング
  • トラブルシューティングガイド

container-orchestration.mdの内容:

  • Docker Compose(ローカル開発)へのデプロイ
  • Kubernetes(自動スケーリングによるエンタープライズ規模)
  • Amazon ECS(AWSネイティブのオーケストレーション)
  • Google Cloud Run(サーバーレスコンテナ)
  • Azure Container Instances
  • Digital Ocean App Platform

構成例、コマンド、自動スケーリングの設定、および監視が含まれます。

ワークフローの意思決定ツリー

1. どの環境ですか?

  • 開発環境Dockerfile.development(ホットリロード、すべての依存関係)
  • 本番環境Dockerfile.production(最小限、安全、最適化)
  • 静的エクスポートDockerfile.nginx(最小のフットプリント)

2. シングルコンテナまたはマルチコンテナですか?

  • シングル → Dockerfileのみを生成
  • マルチdocker-compose.ymlを生成(アプリ + データベース、マイクロサービス)

3. どのレジストリですか?

  • Docker Hubdocker.io/username/image
  • AWS ECR123456789012.dkr.ecr.region.amazonaws.com/image
  • Google GCRgcr.io/project-id/image
  • Azure ACRregistry.azurecr.io/image

4. デプロイメントプラットフォームは?

  • Kubernetesreferences/container-orchestration.mdのK8sセクションを参照
  • ECS → ECSタスク定義の例を参照
  • Cloud Run → デプロイメントコマンドを参照
  • Docker Compose → 提供されているcomposeファイルを使用

5. 最適化は必要ですか?

  • イメージサイズ → マルチステージビルド、Alpineベース
  • ビルド速度 → レイヤーキャッシュ、BuildKit
  • セキュリティ → 非rootユーザー、脆弱性スキャン
  • パフォーマンス → リソース制限、ヘルスチェック

使用例

例1: 本番環境向けにNext.jsアプリをコンテナ化する

ユーザー: "本番環境向けにNext.jsアプリをコンテナ化したい"

手順:

  1. assets/Dockerfile.productionをプロジェクトルートにDockerfileとしてコピー
  2. assets/.dockerignoreをプロジェクトルートにコピー
  3. ビルド: ./docker-build.sh -e prod -n my-app -t v1.0.0
  4. テスト: ./docker-run.sh -i my-app -t v1.0.0 -p 3000:3000 -d
  5. プッシュ: ./docker-push.sh -n my-app -t v1.0.0 --repo username/my-app

例2: Docker Composeを使用した開発

ユーザー: "ローカル開発用にDocker Composeを設定したい"

手順:

  1. assets/Dockerfile.developmentassets/docker-compose.ymlをプロジェクトにコピー
  2. docker-compose.ymlでサービスをカスタマイズ
  3. 起動: docker-compose up -d
  4. ログ: docker-compose logs -f app-dev

例3: Kubernetesへのデプロイ

ユーザー: "コンテナ化されたアプリをKubernetesにデプロイしたい"

手順:

  1. イメージをビルドしてレジストリにプッシュ
  2. references/container-orchestration.mdのKubernetesセクションを確認
  3. K8sマニフェスト(デプロイメント、サービス、イングレス)を作成
  4. 適用: kubectl apply -f deployment.yaml
  5. 確認: kubectl get pods && kubectl logs -f deployment/app

例4: AWS ECSへのデプロイ

ユーザー: "AWS ECS Fargateにデプロイしたい"

手順:

  1. ビルドしてECRにプッシュ
  2. references/container-orchestration.mdのECSセクションを確認
  3. タスク定義JSONを作成
  4. 登録: aws ecs register-task-definition --cli-input-json file://task-def.json
  5. サービスを作成: aws ecs create-service --cluster my-cluster --service-name app --desired-count 3

ベストプラクティス

セキュリティ

✅ 本番環境にはマルチステージビルドを使用する ✅ 非rootユーザーとして実行する ✅ 特定のイメージタグを使用する(latestではない) ✅ 脆弱性をスキャンする ✅ シークレットをハードコードしない ✅ ヘルスチェックを実装する

パフォーマンス

✅ レイヤーキャッシュの順序を最適化する ✅ Alpineイメージを使用する(約85%小型化) ✅ 並列ビルドのためにBuildKitを有効にする ✅ リソース制限を設定する ✅ 圧縮を使用する

メンテナンス性

✅ 複雑な手順にはコメントを追加する ✅ 柔軟性のためにビルド引数を使用する ✅ DockerfileをDRYに保つ ✅ すべての構成をバージョン管理する ✅ 環境変数をドキュメント化する

(原文がここで切り詰められています)

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

Docker Containerization Skill

Overview

Generate production-ready Docker configurations for modern web applications, particularly Next.js and Node.js projects. This skill provides Dockerfiles, docker-compose setups, bash scripts for container management, and comprehensive deployment guides for various orchestration platforms.

Core Capabilities

1. Dockerfile Generation

Create optimized Dockerfiles for different environments:

Production (assets/Dockerfile.production):

  • Multi-stage build reducing image size by 85%
  • Alpine Linux base (~180MB final image)
  • Non-root user execution for security
  • Health checks and resource limits

Development (assets/Dockerfile.development):

  • Hot reload support
  • All dev dependencies included
  • Volume mounts for live code updates

Nginx Static (assets/Dockerfile.nginx):

  • Static export optimization
  • Nginx reverse proxy included
  • Smallest possible footprint

2. Docker Compose Configuration

Multi-container orchestration with assets/docker-compose.yml:

  • Development and production services
  • Network and volume management
  • Health checks and logging
  • Restart policies

3. Bash Scripts for Container Management

docker-build.sh - Build images with comprehensive options:

./docker-build.sh -e prod -t v1.0.0
./docker-build.sh -n my-app --no-cache --platform linux/amd64

docker-run.sh - Run containers with full configuration:

./docker-run.sh -i my-app -t v1.0.0 -d
./docker-run.sh -p 8080:3000 --env-file .env.production

docker-push.sh - Push to registries (Docker Hub, ECR, GCR, ACR):

./docker-push.sh -n my-app -t v1.0.0 --repo username/my-app
./docker-push.sh -r gcr.io/project --repo my-app --also-tag stable

docker-cleanup.sh - Free disk space:

./docker-cleanup.sh --all --dry-run  # Preview cleanup
./docker-cleanup.sh --containers --images  # Clean specific resources

4. Configuration Files

  • .dockerignore: Excludes unnecessary files (node_modules, .git, logs)
  • nginx.conf: Production-ready Nginx configuration with compression, caching, security headers

5. Reference Documentation

docker-best-practices.md covers:

  • Multi-stage builds explained
  • Image optimization techniques (50-85% size reduction)
  • Security best practices (non-root users, vulnerability scanning)
  • Performance optimization
  • Health checks and logging
  • Troubleshooting guide

container-orchestration.md covers deployment to:

  • Docker Compose (local development)
  • Kubernetes (enterprise scale with auto-scaling)
  • Amazon ECS (AWS-native orchestration)
  • Google Cloud Run (serverless containers)
  • Azure Container Instances
  • Digital Ocean App Platform

Includes configuration examples, commands, auto-scaling setup, and monitoring.

Workflow Decision Tree

1. What environment?

  • DevelopmentDockerfile.development (hot reload, all dependencies)
  • ProductionDockerfile.production (minimal, secure, optimized)
  • Static ExportDockerfile.nginx (smallest footprint)

2. Single or Multi-container?

  • Single → Generate Dockerfile only
  • Multi → Generate docker-compose.yml (app + database, microservices)

3. Which registry?

  • Docker Hubdocker.io/username/image
  • AWS ECR123456789012.dkr.ecr.region.amazonaws.com/image
  • Google GCRgcr.io/project-id/image
  • Azure ACRregistry.azurecr.io/image

4. Deployment platform?

  • Kubernetes → See references/container-orchestration.md K8s section
  • ECS → See ECS task definition examples
  • Cloud Run → See deployment commands
  • Docker Compose → Use provided compose file

5. Optimizations needed?

  • Image size → Multi-stage builds, Alpine base
  • Build speed → Layer caching, BuildKit
  • Security → Non-root user, vulnerability scanning
  • Performance → Resource limits, health checks

Usage Examples

Example 1: Containerize Next.js App for Production

User: "Containerize my Next.js app for production"

Steps:

  1. Copy assets/Dockerfile.production to project root as Dockerfile
  2. Copy assets/.dockerignore to project root
  3. Build: ./docker-build.sh -e prod -n my-app -t v1.0.0
  4. Test: ./docker-run.sh -i my-app -t v1.0.0 -p 3000:3000 -d
  5. Push: ./docker-push.sh -n my-app -t v1.0.0 --repo username/my-app

Example 2: Development with Docker Compose

User: "Set up Docker Compose for local development"

Steps:

  1. Copy assets/Dockerfile.development and assets/docker-compose.yml to project
  2. Customize services in docker-compose.yml
  3. Start: docker-compose up -d
  4. Logs: docker-compose logs -f app-dev

Example 3: Deploy to Kubernetes

User: "Deploy my containerized app to Kubernetes"

Steps:

  1. Build and push image to registry
  2. Review references/container-orchestration.md Kubernetes section
  3. Create K8s manifests (deployment, service, ingress)
  4. Apply: kubectl apply -f deployment.yaml
  5. Verify: kubectl get pods && kubectl logs -f deployment/app

Example 4: Deploy to AWS ECS

User: "Deploy to AWS ECS Fargate"

Steps:

  1. Build and push to ECR
  2. Review references/container-orchestration.md ECS section
  3. Create task definition JSON
  4. Register: aws ecs register-task-definition --cli-input-json file://task-def.json
  5. Create service: aws ecs create-service --cluster my-cluster --service-name app --desired-count 3

Best Practices

Security

✅ Use multi-stage builds for production ✅ Run as non-root user ✅ Use specific image tags (not latest) ✅ Scan for vulnerabilities ✅ Never hardcode secrets ✅ Implement health checks

Performance

✅ Optimize layer caching order ✅ Use Alpine images (~85% smaller) ✅ Enable BuildKit for parallel builds ✅ Set resource limits ✅ Use compression

Maintainability

✅ Add comments for complex steps ✅ Use build arguments for flexibility ✅ Keep Dockerfiles DRY ✅ Version control all configs ✅ Document environment variables

Troubleshooting

Image too large (>500MB) → Use multi-stage builds, Alpine base, comprehensive .dockerignore

Build is slow → Optimize layer caching, use BuildKit, review dependencies

Container exits immediately → Check logs: docker logs container-name → Verify CMD/ENTRYPOINT, check port conflicts

Changes not reflecting → Rebuild without cache, check .dockerignore, verify volume mounts

Quick Reference

# Build
./docker-build.sh -e prod -t latest

# Run
./docker-run.sh -i app -t latest -d

# Logs
docker logs -f app

# Execute
docker exec -it app sh

# Cleanup
./docker-cleanup.sh --all --dry-run  # Preview
./docker-cleanup.sh --all            # Execute

Integration with CI/CD

GitHub Actions

- run: |
    chmod +x docker-build.sh docker-push.sh
    ./docker-build.sh -e prod -t ${{ github.sha }}
    ./docker-push.sh -n app -t ${{ github.sha }} --repo username/app

GitLab CI

build:
  script:
    - chmod +x docker-build.sh
    - ./docker-build.sh -e prod -t $CI_COMMIT_SHA

Resources

Scripts (scripts/)

Production-ready bash scripts with comprehensive features:

  • docker-build.sh - Build images (400+ lines, colorized output)
  • docker-run.sh - Run containers (400+ lines, auto conflict resolution)
  • docker-push.sh - Push to registries (multi-registry support)
  • docker-cleanup.sh - Clean resources (dry-run mode, selective cleanup)

References (references/)

Detailed documentation loaded as needed:

  • docker-best-practices.md - Comprehensive Docker best practices (~500 lines)
  • container-orchestration.md - Deployment guides for 6+ platforms (~600 lines)

Assets (assets/)

Ready-to-use templates:

  • Dockerfile.production - Multi-stage production Dockerfile
  • Dockerfile.development - Development Dockerfile
  • Dockerfile.nginx - Static export with Nginx
  • docker-compose.yml - Multi-container orchestration
  • .dockerignore - Optimized exclusion rules
  • nginx.conf - Production Nginx configuration

同梱ファイル

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