docker-patterns
OfficialDocker イメージの構築、最適化、マルチステージビルド、ネットワーク、ボリューム管理。本番環境デプロイメント用のベストプラクティス。
What this skill does
When applied, it prepends a system prompt before your request is sent — no extra calls and no change to how you are billed beyond the added tokens.
---
name: docker-patterns
description: Docker イメージの構築、最適化、マルチステージビルド、ネットワーク、ボリューム管理。本番環境デプロイメント用のベストプラクティス。
origin: ECC
---
# Docker パターン
本番環境対応のDocker イメージとコンテナ。
## 使用時期
- Dockerfile を書く
- イメージサイズを最適化
- マルチステージビルド
- ネットワークと永続化を設定
- デプロイメント戦略
## Dockerfile ベストプラクティス
### 1. イメージサイズを最小化
```dockerfile
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
FROM node:18-alpine
WORKDIR /app
COPY --from=build /app/node_modules ./node_modules
COPY . .
CMD ["node", "server.js"]
```
### 2. レイヤー最適化
```dockerfile
# キャッシュを活用するため、変更がない部分を上に
FROM node:18-alpine
WORKDIR /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
```
## チェックリスト
- [ ] イメージサイズ最適化
- [ ] セキュリティスキャン
- [ ] ヘルスチェック
- [ ] ログ管理
- [ ] ネットワーク構成
詳細については、ドキュメントを参照してください。
Use this skill
Add a "skill" field with the skill’s ID to your chat completion request. It is applied server-side before your prompt is sent — no extra calls.
{
"model": "gpt-4o-mini",
"skill": "imp-c081f805-dae4-4ec3-b45a-822cbd266d02",
"messages": [{ "role": "user", "content": "…" }]
}Install the skill, enable it in your dashboard and (optionally) limit it to specific models. It then applies automatically to every matching request — with no "skill" field to send each time.
Set it up in your dashboardMore skills
Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.
Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.
List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.
Create, search, and manage Bear notes via grizzly CLI.
Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.
BluOS CLI (blu) for discovery, playback, grouping, and volume.
Capture frames or clips from RTSP/ONVIF cameras.
Search, install, update, sync, or publish agent skills with the ClawHub CLI and registry.