Reputation: 755
I have a weird case where I need to map a directory inside a already mapped directory inside a container.
e.g. I already have a mapping - host/dir1:/app
. Now I want to map host/wwwroot:/app/wwwroot
. When I add another -v
for host/wwwroot:/app/wwwroot
, docker complains that the volume is already mapped.
Is there a way to get around that?
Upvotes: 0
Views: 323
Reputation: 1450
Ok this is a bit unorthodox but it worked (I am using an ubuntu image on the following example):
On your host run the following:
cd host/dir1
ln -s ../inside_mount wwwroot
docker run -it -v host/dir1:/app -v host/wwwroot:/inside_mount ubuntu
You are actually binding under different directories inside the container but the soft link creates the desired result. On your host the soft link is dangling but inside the container it will point to the correct directory.
Upvotes: 1