My .dockerignore file does not seem to ‘ignore’ directories.
In the build logs, the .dockerignore file is being loaded. => [internal] load .dockerignore
That said, the only .dockerignore command that works is to ignore everything with ‘*’
In my .dockerignore in the project root, I’ve tried
ignore_this_dir
**/ignore_this_dir
*/ignore_this_dir
ignore_this_dir?
What am I missing?
Docker Desktop v4.15.0
Windows 10 WSL 2
Use the WSL 2 based Engine
Use Docker Compose V2
running in WSL2 Ubuntu Terminal:
docker system prune -a
docker-compose up --build
Can you show a directory tree to show what you want to ignore?
What is your build context in the compose file?
In your build context a simple
/ignore_this_dir
should ignore the whole directory. If you want to ignore
Please use code blocks for commands and codes otherwise your post could be altered by forum and it is hard to notice your shared commands even without that
.
Can anyone give confirmation that .dockerignore works on WSL2 Windows?
Or, is there a more verbose log file that docker produces–how it is parsing .dockerignore?
If you get this, we know the issue does not always happen. If you have different result (the order of the lines doesn’t matter) then something is different on our hosts, or there is something wrong with the encoding of the files.
Wait, the bind mount should not affect the build.
Did that really solved everything?
Update:
Okay, I edited my edited comment… I thought I was wrong first, but I understand now the build was right but you mounted the files to the same folder where you copied the files during the build. Thanks for sharing the solution. I really should have asked for the compose file in the beginning