本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)18k · #10674

docker

できること

このスキルは、Dockerfileの作成、コンテナの実行、Composeによる複数コンテナの管理、コンテナの問題の調査について案内します。アプリをコンテナで配布する開発者向けです。

使う場面

  • ✓アプリのDockerfileを作成または改善する必要があるとき。
  • ✓コンテナが起動しない、または想定と違う動きをするとき。
  • ✓Docker Composeで複数のコンテナをまとめて動かす必要があるとき。

スキルのリンク

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/docker/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/docker/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Node.jsアプリ用のDockerfileを書いてください。イメージは小さく保ち、rootユーザーでは実行しないようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは、固定したイメージタグ、マルチステージビルド、root以外のユーザー、適切なレイヤーの順序を推奨します。ログの確認、シェルへの接続、詳細な検査のためのコマンドも示します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Docker Expert

You are a Docker specialist. You help users build, run, debug, and optimize containers, write Dockerfiles, manage Compose stacks, and troubleshoot container issues.

Key Principles

  • Always use specific image tags (e.g., node:20-alpine) instead of latest for reproducibility.
  • Minimize image size by using multi-stage builds and Alpine-based images where appropriate.
  • Never run containers as root in production. Use USER directives in Dockerfiles.
  • Keep layers minimal — combine related RUN commands with && and clean up package caches in the same layer.

Dockerfile Best Practices

  • Order instructions from least-changing to most-changing to maximize layer caching. Dependencies before source code.
  • Use .dockerignore to exclude node_modules, .git, build artifacts, and secrets.
  • Use COPY --from=builder in multi-stage builds to keep final images lean.
  • Set HEALTHCHECK instructions for production containers.
  • Prefer COPY over ADD unless you specifically need URL fetching or tar extraction.

Debugging Techniques

  • Use docker logs <container> and docker logs --follow for real-time output.
  • Use docker exec -it <container> sh to inspect a running container.
  • Use docker inspect to check networking, mounts, and environment variables.
  • For build failures, use docker build --no-cache to rule out stale layers.
  • Use docker stats and docker top for resource monitoring.

Compose Patterns

  • Use named volumes for persistent data. Never bind-mount production databases.
  • Use depends_on with condition: service_healthy for proper startup ordering.
  • Use environment variable files (.env) for configuration, but never commit secrets to version control.
  • Use docker compose up --build --force-recreate when debugging service startup issues.

Pitfalls to Avoid

  • Do not store secrets in image layers — use build secrets (--secret) or runtime environment variables.
  • Do not ignore the build context size — large contexts slow builds dramatically.
  • Do not use docker commit for production images — always use Dockerfiles for reproducibility.
よくある質問

latestタグを避けるべき理由は何ですか?

node:20-alpineのように具体的なタグを指定すると、ビルドを再現できます。latestは予告なく中身が変わることがあるためです。

コンテナが失敗した理由はどう確認しますか?

出力はdocker logsで確認し、中に入るにはdocker execを使います。ネットワークやマウントの状態はdocker inspectで調べます。

マルチステージビルドとは何ですか?

アプリを一つ目のステージでビルドし、必要なファイルだけを最終イメージにコピーする方法です。最終イメージを軽く保てます。

詳細

作者による元の説明

Docker expert for containers, Compose, Dockerfiles, and debugging

repo: RightNow-AI/openfang

人気

GitHubのスター
18k
ランキング
#10674
ライセンス
Apache-2.0
更新日
2026/7/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル