📦.dockerignore
Also known as .dockerignore File, Docker Ignore File, dockerignore
A file that lists what to leave out when an image is built.
Think of it like
Think of it like a list of things not to pack for a trip.
Example
Emma's project folder holds 900 MB of downloaded packages and a .env file with passwords. Two lines in .dockerignore keep both out of the build.
Why it matters
Everything not left out is sent to the builder and can end up in the image. That includes passwords.
Definition
Example code
console
$ cat .dockerignore
node_modules
.env
*.log
.gitCommon mistake
Key takeaways
- 1A leave-out list. One pattern on each line.
- 2The top folder. It sits at the root of the build.
- 3Faster and safer. Less to send and no secrets inside.