Docker Patterns

affaan-m/ECC/docs/ja-JP/skills/docker-patterns

by affaan-mef648e01899ba3e8dc6371642deaaf64b4477775No license275K starsListed Oct 9, 2026Updated Oct 9, 2026Repository updated 4 days ago

Docker イメージの構築、最適化、マルチステージビルド、ネットワーク、ボリューム管理。本番環境デプロイメント用のベストプラクティス。

Instructions onlyDevOps & Cloud
AI-generated overview

Guides writing production-ready Dockerfiles, multi-stage builds, image optimization, networking and volumes.

What it does
Provides Docker best-practice guidance covering Dockerfile authoring, image size minimization, layer caching, multi-stage builds, security measures such as non-root users and health checks, docker-compose service definitions, and a deployment checklist. It is instruction-only and produces written guidance and example Dockerfile and compose snippets rather than running anything.
When to use it
Use when writing or reviewing a Dockerfile, optimizing image size, setting up multi-stage builds, configuring container networking or persistent volumes, or planning a container deployment strategy.
Requirements
No tools, packages, or credentials are required; it ships no scripts and only provides instructions and example configuration snippets.

Docker パターン

本番環境対応のDocker イメージとコンテナ。

使用時期

  • Dockerfile を書く
  • イメージサイズを最適化
  • マルチステージビルド
  • ネットワークと永続化を設定
  • デプロイメント戦略

Dockerfile ベストプラクティス

1. イメージサイズを最小化

dockerfile
FROM node:18-alpine AS buildWORKDIR /appCOPY package*.json ./RUN npm install
FROM node:18-alpineWORKDIR /appCOPY --from=build /app/node_modules ./node_modulesCOPY . .CMD ["node", "server.js"]

2. レイヤー最適化

dockerfile
# キャッシュを活用するため、変更がない部分を上にFROM node:18-alpineWORKDIR /app
# 依存関係(変更が少ない)COPY package*.json ./RUN npm install
# アプリケーション(頻繁に変更)COPY . .
CMD ["node", "server.js"]

3. セキュリティ

  • root ユーザーで実行しない
  • シークレットを避ける
  • ヘルスチェック追加
dockerfile
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \  CMD node healthcheck.js

docker-compose

yaml
version: '3.8'services:  app:    build: .    ports:      - "3000:3000"    environment:      - NODE_ENV=production    volumes:      - ./data:/app/data    depends_on:      - db  db:    image: postgres:15    environment:      - POSTGRES_PASSWORD=secret

チェックリスト

  • イメージサイズ最適化
  • セキュリティスキャン
  • ヘルスチェック
  • ログ管理
  • ネットワーク構成

詳細については、ドキュメントを参照してください。

Source and attribution

Source:affaan-m/ECCindocs/ja-JP/skills/docker-patternsat commitef648e0

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal