Docker: Mount directory from one container to a specific path in another


When we use "-v" argument in "docker run" command, we can specify {src path from host}:{path in container}, e.g

docker run -v /var/volumns/v1:/var/docker/v1ref ...

But, how about mounting a data-only container?

docker run --volumes-from data-only-container:<here is mode, ro or rw>

How I can achieve the same when using "-v"? Can I mount it to a specific folder?

Best Answer

I am afraid that the direct answer to your question is: no, you can't. volumes-from import the volumes exactly as they are defined in the other container.

Since docker 1.9 volume containers are being replaced with named volumes as the recommended practice. With named volumes you can mount it wherever you want :

docker volume create --name data
docker run -v data:/var/docker/v1ref ...