Skip to content
Latchkey

What Is a .dockerignore file?

a .dockerignore file explained, including what it does and how it matters in CI/CD.

A .dockerignore file lists files and directories to exclude from the Docker build context.

What it is

It keeps node_modules, .git, and build output out of the context sent to the daemon, which speeds builds and avoids leaking secrets into images.

Why it matters in CI/CD

In CI, a good .dockerignore dramatically cuts the build context size and build time, and prevents busting the layer cache on irrelevant file changes.

Key takeaways

  • .dockerignore trims the build context.
  • It speeds builds and avoids leaks.
  • Improves Docker layer cache hits.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →