Reputation: 185
I am creating two containers running 2 different applications. Container A, exposes 2 directories say /opt/appA and /home/userA/runtime. Both are needed to be referred to by container B (--volumes-from A). B in turn should expose a volume /home/userB/runtime, which container A needs (--volumes-from B) when it starts.
Q. is how to achieve this? Because when I start/run container 'A', container 'B' does not yet exist (--volumes-from B does not work) and vice versa for B.
Is there a way out of this?
Upvotes: 3
Views: 255
Reputation: 1324073
Simply create separate volumes (and use them in A and B) with the docker 1.9 docker volume create
command.
That way, A and B can mount those volumes when they are launched.
One volume can be mounted (-v
) by multiple containers.
$ docker volume create --name optA
optA
$ docker run --name=A -d -v optA:/opt/appA busybox ls /opt/appA
$ docker run --name=B -d -v optA:/opt/appA busybox ls /opt/appA
No more --volume-from
needed.
Upvotes: 2