I have a huge project. I want to include only files like package.json and requirements.txt in the build context. To do that, I tried adding a .dockerignore that excludes * and includes specific files (!foo/requirements.txt).
If I try to use * in .dockerignore and ! to include specific files, it takes a really long time (if the context directory is large).
> du -sh .
1.1G . # this is in a BIG context
> cat empty.dock
FROM ubuntu
> cat .dockerignore
*
!foo/requirements.txt
> docker build -f empty.dock .
# HANGS for a really long time
Sending build context... etc etc
Now, if I remove the included file !foo/bar.txt from .dockerignore, then it's super fast!
> cat .dockerignore
*
> docker build -f empty.dock .
Sending build context... etc etc # INSTANT! :D
Any idea what's up?