I'm new to Docker and am excited about using the --volumes-from
feature but there's something I'm not understanding.
If I want to use --volumes-from
with two data-only containers, each of which exports volumes named /srv
, how to I prevent the volume paths from colliding? I can map volume names when creating a bind mount using [host-dir]:[container-dir]
; how do I do that with --volumes-from
?
So what I want would look something like this:
docker run --name=DATA1 --volume=/srv busybox true
docker run --name=DATA2 --volume=/srv busybox true
docker run -t -i -rm --volumes-from DATA1:/srv1 --volumes-from DATA2:/srv2 ubuntu bash
It can be done, but it is not supported at this moment in docker commandline interface.
How-to
Find the volumes directories:
So, you can automate this, and mount these directories at mount points of your choice:
now, mount these volumes by real directories instead of the --volumes-from:
IMO, the functionality is identical, because this is the same thing that is done when using
--volumes-from
.For completeness...
The "--volumes-from=container" just map over the filesystem, like
mount --bind
If you want to change the path, Jiri's answer is (currently) the only way. But if you are in a limited environment you might want to use dockers built in inspect parsing capabilities:
this probably even works with the old bash version that comes with boot2docker.