.dockerignore ファイルとは?
.dockerignore ファイルの解説。何をするものか、そして CI/CD でなぜ重要かを含みます。
.dockerignore ファイルは、Docker の build コンテキストから除外するファイルとディレクトリを列挙します。
何であるか
node_modules、.git、build 出力をデーモンに送られるコンテキストから除外し、build を速くし、イメージへの secret の漏洩を防ぎます。
CI/CD でなぜ重要か
CI では、優れた .dockerignore が build コンテキストのサイズと build 時間を劇的に削減し、無関係なファイル変更で layer cache が無効化されるのを防ぎます。
重要なポイント
- .dockerignore は build コンテキストを削減します。
- build を速くし、漏洩を防ぎます。
- Docker の layer cache のヒット率を向上させます。
関連ガイド
What Is a Dockerfile? The Recipe for Building an ImageA Dockerfile is a text recipe of instructions that builds a Docker image. Learn the key instructions, layerin…
What Is Docker Layer Caching? Why the Second Build Is FastDocker layer caching reuses unchanged layers so rebuilds skip redundant work. Learn how the cache invalidates…