dockerignore in Docker
From the Docker cheat sheet ยท Dockerfile ยท verified Nov 2026
.dockerignore
Exclude files from the build context to speed up builds and avoid leaking secrets
bash
# .dockerignore
node_modules
.git
.env
*.md
dist
.DS_Store๐ก Without .dockerignore, Docker sends EVERYTHING in the directory to the build daemon
โก Always ignore node_modules โ they get reinstalled with npm ci inside the image
๐ Ignore .env files to prevent secrets from being baked into the image
๐ข Like .gitignore (wildcards, !negation), but patterns match from the root - use **/*.md for any depth
dockerignorebuildsecurity
Continue with Docker
Save the full cheat sheet or work through every related task.