I'd like to bind-mount my entire project into the container so updates on the host to the source are reflected in the container, but not have it shadow specific directories that were created there during the image build process. These files contain binary libraries that are architecture-specific (i.e. MacOS vs. Linux).
Here's a simple example of what I'm trying to accomplish - think of readme.txt as a binary:
$tree
.
├── Dockerfile
└── lib
└── readme.txt
1 directory, 2 files
$cat lib/readme.txt
this is from the host
See Dockerfile below
$docker run -t -i -v /path/to/test/:/test --rm foobar/test
root@a92565a735f7:/test# cat lib/readme.txt
this is from the host
root@a92565a735f7:/test# cat /outside/readme.txt
this is from the container
How to devise it so the volume doesn't shadow readme.txt
? Obviously, I have a copy of the binary files I need outside the WORKDIR
in /outside
, and I could try to update the source to use that, but it is a bit of a pain, since all the software, including 3rd party components, etc. expect a standard directory structure.
Another possible solution is to only bind-mount all the specific files and directories I want and exclude others (e.g. /test/lib
), but this gets to be a maintenance headache, too, since there are many files + directories, prone to human err.
One other solution I can think of is to make a data-only container and put all the binary libraries there, export it as a volume and mount that into the runtime container. This seems like the best option so far I guess, but I was hoping someone might have a clever trick that I haven't considered?