Open tbeadle opened 5 years ago
This is by design. type=bind
mounts happen from the same files where COPY
takes them and follow the dockerignore rules. If you want to avoid copying .git
one way is to do the copy from a mount with cp or rsync and ignoring the .git
directory while doing so.
If I have the following Dockerfile:
and the following .dockerignore file:
When I try to build the image, I get this:
If I remove
.git/
from the .dockerignore file, then the image is built successfully. My problem is that we have a large git repo and I don't want to copy the .git directory in to the build context and I don't want to include it with the rest of my source with aCOPY . /app
line, but I do want to be able to do git operations within the build, like generating version numbers from git tags and such. So I figured usingRUN --mount=bind
would be the solution, but it appears that you can only mount stuff that's been copied in to the build context (i.e. not in .dockerignore). Is there a solution to my problem?