A .dockerignore file lists files and directories Docker should exclude from the build context. Excluded content is not sent to the Docker Engine, reducing transfer time and potentially shrinking the resulting image. section 17.1
Use .dockerignore when:
- A Dockerfile uses COPY . . but the context contains documentation, images, or other unnecessary files. section 17.1
- A nested project makes precise COPY patterns awkward or convoluted. section 17.1
- Local build output must not be copied into a Docker multi-stage build. section 17.1
Reduce the build context
Create .dockerignore in the build directory and exclude the docs folder. A no-cache build with the original context sends 2 MB; the ignored context sends about 190 bytes, and the resulting v4 image is 2 MB smaller.



