It's doable but you must "think container" if you have symlinks to random files in random locations, then it's actually may not be worth it.
But consider this working worth scenario:
You have 2 folders, one with real files, and one with symlinks to real:
/static-data/
|_ data-file1.dat
|_ data-file2.dat
|
|__index/
|_a.txt
|_b.txt
/other/
|_ data-file1.dat -> /static-data/data-file1.dat
|_ data-file2.dat -> /static-data/data-file2.dat
|
|__index/
|_a.txt
|_b.txt
Now if you mount /other:/data
for a container when you ls -lah /data
you'll see broken links because /static-data
doesn't exist in the container. The solution is to create broken links in the Host, assuming /other
is not directly important to host to be broken
so your new structure would be:
/other/
|_ data-file1.dat -> /mirror/data-file1.dat
|_ data-file2.dat -> /mirror/data-file2.dat
|
|__index/
|_a.txt
|_b.txt
You then need 2 mount records
/other:/data
/static-data:/mirror
Now when you run a container, the symlinks that are broken for Host, are not broken in the container so /data/data-file1.dat -> /mirror/data-file1.dat
and container has mounted /mirror
thus the symlink is pointing to /static-data/data-file1.dat
from the host
If you don't want broken symlinks in the host then you could mount both directories as
/other:/data
/static-data:/static-data
Now the links can be valid in Host and the container.
As you can see this is possible, I tested that and it works, but it's worth only for obvious clusters of files. If it's all random, the you would end-up mounting a lot of dirs or maybe single files, to reflect Host structure in the container