I'm trying to exclude from my Docker image all hidden files (starting with a dot) from all directories of the project.
To exclude .git
and .gitingore
: .git*
To exclude all .keep
files: **/.keep
works
For all hidden files, I tried: **/.*
, But that excludes all files containing a dot, like **/*.*
does.
.dockerignore files try to follow Go's filepath.Match rules with the addition of a glob like **
matching any directories in a path. So they aren't exactly the same as glob patterns, or even trying to be. In fact, Docker implemented its own parser so it's not even using filepath.Match
any more.
Using dir/.*
and dir/*/.*
works as expected. But dir/**/.*
doesn't seem to work all the time.
This specific issue should be resolved, but I think I've seen the same behaviour in 1.13.1 in certain circumstances.
So with a .dockerignore
of dir/**/.*
the file dir/file.ext
will be excluded but dir/subdir/file.ext
will be included.
This is probably worth opening a new issue with Docker if you have a specific reproducible case on 1.13.
The issue has been fixed but the commit has not been merged into a released branch yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With