🐋.dockerignore Generator

Path sizes plus patterns to context savings

Compared.dockerignore.gitignore
Matching engineGo filepath.Match rules plus **git pattern rules
Pattern baseAlways the build context rootWithout a slash it matches at any depth
Deep matchingNeeds **/foo to reach nested pathsfoo alone also matches nested paths
Directory-only formNo trailing-slash distinctionfoo/ matches directories only
! exceptionsThe last matching line decidesA file under an excluded directory cannot be re-included

You Might Also Need

See how much the build context shrinks

docker build sends the files in the context to the builder before anything else runs. Enter the size of each path and your exclude patterns, and the tool reports which paths drop out, how many MB the context becomes, and the reduction as a percentage, along with a ready-to-paste .dockerignore. Each path is decided by the last line that matches its most specific form.

Copying a .gitignore straight over does not work. .dockerignore follows Go filepath.Match rules and always reads patterns from the context root, so reaching nested paths needs an explicit double star, and there is no directory-only form. The comparison table below lists the differences, following the Docker documentation checked in October 2026.

Sizes are a plain sum of what you type. Transfer compression, cache reuse and symbolic links are not modelled, so the real transfer can differ. The presets are a widespread convention rather than a specification, so check that nothing the build needs was excluded.

Frequently Asked Questions

Can I copy my .gitignore over?

Not recommended, because the syntax differs. .dockerignore always reads patterns from the context root and has no directory-only form, so a pattern that caught every depth in git may catch only the top level here.

What if excluding a path breaks the build?

Usually a file that COPY or ADD needs was excluded too. Look for paths whose state turned to excluded, and add an exception line starting with an exclamation mark below the rule that excluded it. The last matching line decides.

Does the calculated size match the real transfer?

No. It is a sum of the MB values you typed and ignores compression, cache reuse and symbolic links. Use it to judge the share you are cutting, and read the build log for the exact number.