Difficulty: Beginner
What is a .dockerignore file and why is it important for build performance?
It works exactly like `.gitignore`. It prevents specific files/directories from being sent to the Docker daemon as part of the 'build context'.
**Commonly ignored**: `node_modules`, `.git`, `.env`, and documentation.
# .dockerignore
node_modules
.git
.env
dist
npm-debug.log
Dockerfile
.dockerignore
By ignoring 'node_modules', the 'COPY . .' command won't copy your local, probably OS-specific modules into the Linux-based container.
Dockerfile, Build Context, Optimization