medium · dockerfile/missing-dockerignore

.dockerignore file is missing

Without .dockerignore, the build context may include .git, node_modules, secrets, and other unnecessary files.

Why it breaks the cache

Larger contexts slow builds and can leak sensitive files.

Bad Dockerfile

# no .dockerignore next to the Dockerfile

Good Dockerfile

node_modules/
.git/
dist/
*.log
.env*

CLI

layerlint rules explain missing-dockerignore

All docs · Download