What does `.dockerignore` do?
BeginnerConceptDockerfile Instructions & Builds
Answer
It excludes files from the build context using gitignore-like patterns, speeding up builds, preventing cache invalidation from irrelevant changes, and keeping secrets out.
.git
node_modules
**/*.log
.env
Dockerfile*
!Dockerfile
Patterns are relative to the context root and ! re-includes a path.
More on Dockerfile Instructions & Builds
What is the difference between `RUN`, `CMD` and `ENTRYPOINT`?BeginnerHow do ENTRYPOINT and CMD combine?IntermediateShell form vs exec form: what is the practical difference?Advanced`COPY` vs `ADD`?BeginnerWhat is the build context and why does it matter?BeginnerHow does the build cache work?Intermediate