Skip to content

CICD-120 · Prevent context bloat ​

Encyclopedia · Docker image building · All snippets

Previous · CICD-119 · Next · CICD-121

1. Where it fits ​

  • Placement .dockerignore at the Docker build context root.
  • Prerequisites Docker Engine or BuildKit on a trusted lab runner.
  • Platforms local-lab.

2. Copy the snippet ​

dockerignore
.git
.venv
.env
node_modules
dist

3. How it works ​

The ignore file removes these paths from the build context sent to Docker. The builder cannot copy an excluded file, even if it exists in the checkout.

4. Verify the result ​

Save to context root .dockerignore and verify needed build files are still present.

Validation untested. Status definitions.