Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding all hidden files with .dockerignore

Tags:

docker

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.

like image 529
Sony Avatar asked Feb 22 '17 21:02

Sony


2 Answers

.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.

like image 172
Matt Avatar answered Oct 07 '22 14:10

Matt


The issue has been fixed but the commit has not been merged into a released branch yet.

like image 31
Sony Avatar answered Oct 07 '22 13:10

Sony