Reputation: 9194
Basically I have a structure like the following:
project/
src/
.unwantedsub/
.dockerignore
Sure enough, whenever I build the image .unwantedsub/
ends up in the image.
I've tried the following:
.unwantedsub
.unwantedsub/
*.unwantedsub/
src/.unwantedsub
src/.unwantedsub/
./src/.unwantedsub
Still shows up in the image. Nothing else is in the .dockerignore
. I'm making sure to destroy the image and make a whole new one, so isn't an issue of looking at the same one. (I did that a few times).
What does work is moving the .dockerignore
into that directory and then .unwantedsub
works. Was hoping to avoid a .dockerignore
in every subdirectory though.
Anyway to get this to work?
Upvotes: 2
Views: 144
Reputation: 62555
Using the following .dockerignore
:
src/.unwantedsub
works well. I've made a complete working example. Run it in an empty directory.
$ mkdir -p src/.unwantedsub
$ echo src/.unwantedsub > .dockerignore
$ echo FROM debian > Dockerfile
$ echo ADD . /data >> Dockerfile
$ docker build -t test .
Sending build context to Docker daemon 4.096kB
Step 1/2 : From debian
---> de8b49d4b0b3
Step 2/2 : Add . /data
---> a15b1ddf86e4
Successfully built a15b1ddf86e4
Successfully tagged test:latest
$ docker run -it test:latest
root@b3c8ffc73b7f:/# ls -l data/src/
total 0
Upvotes: 1