Docker Containerizationのロゴ

Docker Containerization

コミュニティ
Omar-Obando
docker-containerization

Use when containerizing applications with Docker, implementing multi-stage builds, security hardening, image optimization, Docker Compose orchestration, and container best practices. Includes Dockerfile patterns, layer caching, and production-ready configurations.

Add to TypingMind

概要

公開者Omar-Obando
リポジトリqwen-orchestrator
スキル名docker-containerization
スター
53
フォーク
13
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    Omar-ObandoがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Docker Containerization」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/docker-containerization
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Omar-Obando/qwen-orchestrator.git /tmp/qwen-orchestrator
mkdir -p .claude/skills
cp -r /tmp/qwen-orchestrator/skills/docker-containerization .claude/skills/docker-containerization
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでDocker Containerizationを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にDocker Containerizationを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Docker Containerizationは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Docker Containerization Skill — Container Best Practices

Overview

This skill provides comprehensive guidance for containerizing applications with Docker, including multi-stage builds, security hardening, image optimization, and Docker Compose orchestration. Based on Docker official documentation and production best practices.

When to Use

Use this skill when:

  • Containerizing Node.js, Python, PHP, Go, Java, or Rust applications
  • Implementing multi-stage builds for minimal image size
  • Securing Docker containers with non-root users
  • Optimizing Docker image layers and caching
  • Creating Docker Compose configurations for local development
  • Implementing Docker health checks
  • Setting up Docker volumes and data persistence
  • Configuring Docker networks for multi-container apps
  • Building production-ready Docker images
  • Implementing Docker security best practices
  • Optimizing Dockerfile for build cache efficiency
  • Setting up Docker multi-container orchestration
  • Implementing Docker logging and monitoring
  • Creating Docker images for CI/CD pipelines
  • Configuring Docker resource limits

Do NOT use this skill when:

  • Deploying to Kubernetes (use kubernetes-orchestration skill)
  • Setting up cloud infrastructure (use terraform-iac skill)
  • Configuring CI/CD pipelines (use devops-pipeline skill)
  • Building serverless functions (use aws-serverless or cloudflare-workers skill)
  • Managing database schema (use database-design skill)
  • Implementing application code (use backend-developer or frontend-developer skill)
  • Setting up monitoring and alerting (use monitoring skill)

Why avoid: Docker is for containerization, not orchestration or infrastructure. Use the right tool for the job.

Core Concepts

Multi-Stage Build Patterns

PatternUse CaseBenefits
Build → RuntimeCompile languages (Go, Java, Rust)Minimal runtime image
Dependencies → Build → RuntimeNode.js, Python, PHPLayer caching optimization
Build → Test → RuntimeApplications with build-time testsTest isolation
Base → Builder → RunnerComplex applicationsMaximum flexibility

Image Size Targets

Language/FrameworkTarget SizeBase Image
Node.js< 200MBnode:alpine or distroless
Python< 150MBpython:slim
Go< 20MBscratch or distroless
Java< 300MBeclipse-temurin:jre-alpine
PHP< 100MBphp:fpm-alpine
Rust< 15MBscratch or distroless

Multi-Stage Build Examples

Node.js Application

dockerfile
# ============================================
# Stage 1: Dependencies Installation
# ============================================
FROM node:20-alpine AS dependencies

WORKDIR /app

# Copy package files first for layer caching
COPY package.json package-lock.json* ./

# Install production dependencies only
RUN npm ci --only=production --ignore-scripts

# ============================================
# Stage 2: Build Application
# ============================================
FROM node:20-alpine AS builder

WORKDIR /app

# Copy dependencies from previous stage
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .

# Build the application
ENV NODE_ENV=production
RUN npm run build

# ============================================
# Stage 3: Production Runtime
# ============================================
FROM node:20-alpine AS runner

WORKDIR /app

# Create non-root user for security
RUN addgroup --system --gid 1001 appgroup && \
    adduser --system --uid 1001 appuser

# Copy built artifacts from builder
COPY --from=builder --chown=appuser:appgroup /app/dist ./dist
COPY --from=dependencies --chown=appuser:appgroup /app/node_modules ./node_modules

# Use non-root user
USER appuser

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

# Expose port
EXPOSE 3000

# Start application
CMD ["node", "dist/main.js"]

Python Application (FastAPI)

dockerfile
# ============================================
# Stage 1: Dependencies
# ============================================
FROM python:3.12-slim AS dependencies

WORKDIR /app

# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements first for layer caching
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt

# ============================================
# Stage 2: Production Runtime
# ============================================
FROM python:3.12-slim AS runner

WORKDIR /app

# Create non-root user
RUN groupadd --gid 1001 appgroup && \
    useradd --uid 1001 --gid appgroup --shell /bin/bash appuser

# Copy Python dependencies from previous stage
COPY --from=dependencies /install /usr/local

# Copy application code
COPY --chown=appuser:appgroup . .

# Use non-root user
USER appuser

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1

# Expose port
EXPOSE 8000

# Start application with uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Go Application

dockerfile
# ============================================
# Stage 1: Build
# ============================================
FROM golang:1.22-alpine AS builder

WORKDIR /app

# Install build dependencies
RUN apk add --no-cache git

# Copy go.mod and go.sum first for layer caching
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
COPY . .

# Build with static linking
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

# ============================================
# Stage 2: Production Runtime
# ============================================
FROM scratch AS runner

# Copy binary from builder
COPY --from=builder /app/main /app/main

# Copy any necessary files (config, static assets)
# COPY --from=builder /app/config /app/config

# Expose port
EXPOSE 8080

# Start application
CMD ["/app/main"]

Docker Compose Examples

Development Environment

yaml
version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - '3000:3000'
    environment:
      - NODE_ENV=development
      - DATABASE_URL=postgresql://postgres:password@db:5432/app
    volumes:
      - ./src:/app/src
      - /app/node_modules
    depends_on:
      - db
      - redis
    command: npm run dev

  db:
    image: postgres:16-alpine
    ports:
      - '5432:5432'
    environment:
      - POSTGRES_DB=app
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql

  redis:
    image: redis:7-alpine
    ports:
      - '6379:6379'
    volumes:
      - redis_data:/data

  mailpit:
    image: axllent/mailpit
    ports:
      - '8025:8025'
      - '1025:1025'

volumes:
  postgres_data:
  redis_data:

Production Environment

yaml
version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    deploy:
      replicas: 3
      resources:
        limits:
          cpus: '1'
          memory: 512M
        reservations:
          cpus: '0.5'
          memory: 256M
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
    environment:
      - NODE_ENV=production
      - DATABASE_URL=${DATABASE_URL}
      - REDIS_URL=${REDIS_URL}
    networks:
      - app-network
    depends_on:
      - db
      - redis

  db:
    image: postgres:16-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    networks:
      - app-network

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

volumes:
  postgres_data:
  redis_data:

Security Best Practices

Dockerfile Security Checklist

dockerfile
# ✅ GOOD: Non-root user
RUN addgroup --system --gid 1001 appgroup && \
    adduser --system --uid 1001 appuser
USER appuser

# ✅ GOOD: Minimal base image
FROM node:20-alpine
# or
FROM node:20-distroless

# ✅ GOOD: No secrets in Dockerfile
# Use build secrets or runtime environment variables
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret

# ✅ GOOD: Multi-stage builds
FROM node:20-alpine AS builder
# ... build steps ...
FROM node:20-alpine AS runner
COPY --from=builder /app/dist ./dist

# ✅ GOOD: Health checks
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
    CMD node healthcheck.js || exit 1

# ✅ GOOD: Specific image tags
FROM node:20.11.0-alpine
# Not: FROM node:latest

# ✅ GOOD: .dockerignore
# node_modules
# .git
# .env
# *.md
# Dockerfile
# docker-compose.yml

Security Anti-Patterns

dockerfile
# ❌ BAD: Running as root
# No USER directive

# ❌ BAD: Using latest tag
FROM node:latest

# ❌ BAD: Hardcoded secrets
ENV DATABASE_PASSWORD=mysecretpassword

# ❌ BAD: Installing unnecessary packages
RUN apt-get update && apt-get install -y vim curl wget git build-essential

# ❌ BAD: Copying everything
COPY . .

# ❌ BAD: No health check
# Missing HEALTHCHECK directive

Image Optimization

Layer Caching Strategy

dockerfile
# ✅ GOOD: Copy dependency files first
COPY package.json package-lock.json* ./
RUN npm ci
COPY . .

# ❌ BAD: Copy everything before installing dependencies
COPY . .
RUN npm ci

Build Cache Optimization

dockerfile
# Use --mount=type=cache for build caches
RUN --mount=type=cache,target=/root/.npm \
    npm ci

RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -r requirements.txt

RUN --mount=type=cache,target=/root/.gradle \
    ./gradlew build

Production Checklist

Before deploying to production:

  • Multi-stage build implemented
  • Non-root user configured
  • Health check added
  • Specific image tags (not latest)
  • .dockerignore configured
  • No secrets in Dockerfile
  • Minimal base image (alpine/distroless)
  • Resource limits set
  • Logging configured
  • Environment variables documented
  • Image size < target
  • Security scan passed (trivy, grype)
  • Docker Compose for local development
  • Docker Compose for production

Real-World Impact

Before this skill:

  • Large Docker images (1GB+)
  • Running as root
  • No health checks
  • Slow builds due to poor caching
  • Security vulnerabilities

After this skill:

  • Optimized images (< 200MB for Node.js)
  • Non-root user for security
  • Health checks for reliability
  • Fast builds with layer caching
  • Security best practices implemented

Cross-References

  • kubernetes-orchestration - For deploying containers to Kubernetes
  • devops-pipeline - For CI/CD with Docker
  • aws-serverless - For AWS ECS/EKS deployment
  • terraform-iac - For infrastructure provisioning

References

よくある質問

AIスキル「Docker Containerization」では何ができますか?

Use when containerizing applications with Docker, implementing multi-stage builds, security hardening, image optimization, Docker Compose orchestration, and container best practices. Includes Dockerfile patterns, layer caching, and production-ready configurations.

TypingMindでDocker Containerizationを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Docker Containerizationはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにDocker Containerizationをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/docker-containerizationを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Docker Containerizationを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Docker Containerizationで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもDocker Containerizationを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Docker Containerization」は無料ですか?

はい。Omar-ObandoがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇