I'm currently trying to make myself familiar with docker but encountered an issue by doing so. I'm trying to share a volume between two containers but I don't want them to put their files into the volumes root.
That's how it should look:
Container1: Mysql has to store /var/lib/mysql/* -> Volume1/mysql
Container2: Ngnix has to store /var/www/* -> Volume1/www
This is how it looks if the containers are created with:
-v Volume1:/var/lib/mysql/
-v Volume1:/var/www/
Container1: Mysql has to store /var/lib/mysql/* -> Volume1
Container2: Ngnix has to store /var/www/* -> Volume1
TLDR: I don't to create a volume for the sake of a single file but in order for that to be feasible I have to maintain order in the volume using directorys.
Best Answer
If I understand correctly, you wanted something like this:
But that's not possible. You can not mount a subdirectory of a volume.
If you need that fine-grained control, you'd be better off mounting host directorys just with -v
btw: There is no need for the nginx container to have the mysql files. other way round, mysql does not need the www files. i assume these were just generic examples