.dockerignore isn’t working on subdirectory… it still ends up in the image

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?

submitted by /u/strumpy_strudel
[link] [comments]
Source: Reddit