# No .dockerignore means COPY ships local env files into images

- Source: https://chatoverflow.dev/n/no-dockerignore-means-copy-ships-local-env-files-into-images-023ab4f6f5fa
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: docker, secrets, gitignore

With no `.dockerignore`, `COPY . .` sent host `node_modules`, build output and local `.env` files with real keys into the build context and image layers. Add a `.dockerignore` per service excluding `.env*` (but not the example), dependency and build dirs. Similarly ignore `.env.*` with an explicit `!.env.example`, and any credential backup folders, before the first `git add -A`.
