Docker(2/2)

トラブルシュートと本番差分。

ホスト CLI の使い方

早見表

CLI 主用途 インストール(macOS 例) 認証・動作確認 エージェントがよく使う例
gh PR / Issue / CI 状況 brew install gh gh auth status gh pr checks · gh run view
vercel preview deploy · env pull npm i -g vercel vercel whoami vercel link · vercel env pull .env.local
aws ECS / ECR / S3 / ログ brew install awscli aws sts get-caller-identity aws logs tail · aws ecr describe-repositories
supabase ローカル DB · migration brew install supabase/tap/supabase supabase projects list supabase start · supabase db push
docker compose 起動 Docker Desktop docker compose version docker compose up -d · docker compose exec app …

危険操作の扱い

vercel deploy --prod や本番 aws 変更は、エージェントが勝手に実行しないよう 強制確認ルール完了前の検証 を rules に書く。

CLI 別の初手

GitHub CLI (gh)

  1. インストールと確認
    brew install gh
    gh --version
  2. ログイン — ブラウザまたはトークン。gh auth login 後に gh auth statusLogged in を確認する。
  3. リポジトリ紐付け — 作業ディレクトリで gh repo set-default(または gh repo view で remote 確認)。
  4. エージェントの初手 — PR 調査: gh pr checks → 失敗 run: gh run view RUN_ID --log-failed
  5. つまずき — SSO 組織は gh auth login --hostname github.com --web を再実行。トークン scope 不足は repo / read:org を付与。

Vercel CLI

  1. インストールと確認
    npm install -g vercel
    vercel --version
  2. ログインvercel login(ブラウザ)→ vercel whoami
  3. プロジェクト紐付け — 初回 vercel link。環境変数は vercel env pull .env.local.env.local は gitignore)。
  4. エージェントの初手 — preview: vercel(対話)または CI 経由。ローカル確認前に vercel env pull で不足キーを潰す。
  5. つまずき — 複数 team/scope があるときは vercel switch。本番 deploy は要確認(上記「危険操作」)。

AWS CLI

  1. インストールと確認
    brew install awscli
    aws --version
  2. 認証(SSO 推奨)
    aws configure sso --profile myapp-dev
    aws sso login --profile myapp-dev
    export AWS_PROFILE=myapp-dev
    aws sts get-caller-identity

    開発のみ IAM ユーザーの場合は aws configure --profile myapp-dev。本番 CI は OIDC(11.5 CI/CD)を正本とする。

  3. プロファイル確認aws configure list-profiles。複数アカウントでは AWS_PROFILE を rules に明記する。
  4. エージェントの初手 — ログ: aws logs tail /ecs/myapp --follow。イメージ: aws ecr describe-repositories
  5. つまずき — SSO セッションは数時間で切れる。aws sso login を再実行。region 未設定は AWS_DEFAULT_REGION=ap-northeast-1 等を profile に固定。

Supabase CLI(短文)

  • brew install supabase/tap/supabasesupabase loginsupabase projects list
  • ローカル: supabase initsupabase start(Docker 必須。詳細は 11.3
  • マイグレーション: supabase db push / supabase migration new

Docker / Compose(短文)

  • ホストに Docker Desktop(または Linux engine)を入れ、docker compose version が通る状態にする
  • アプリ・DB・テストは 11.3 ローカル開発make up / docker compose exec を正本とする
  • エージェントへの指示は「ホストで compose 起動、実行は exec 経由」と rules で固定する
" aria-label="前後の章">← 運用ルール / Skills →" aria-label="前後の章">← 提出運用 →