Ad space (banner)
AD

Got the fundamentals? A structured Docker course is a fast way to level up.

Find Docker courses on Udemy

Affiliate link. Costs you nothing extra.

🐳Docker Lessons
Lesson 36 / 45

What Is .dockerignore?

This lesson is for anyone whose builds are slow and whose images are surprisingly large. A .dockerignore file lists what to exclude from the build context.

It works like .gitignore: patterns such as node_modules, .git and *.log, one per line.

With node_modules and .git excluded, far less data is sent to the Docker daemon, so builds start faster and images stay smaller.

A common stumble is not having the file at all and unknowingly shipping your entire git history inside the build context.

In real work, a .dockerignore sits next to the Dockerfile in essentially every serious project.

Docker
Try it (type this into the pseudo terminal)
docker build -t myapp .

🧑‍💻 You can type this command into the Docker pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)