Mount Multiple Data Volumes and Multiple Data Volume Containers in Docker
Multiple Data Volumes from a Single Container
Create and run multiple data volumes in a container:
|
|
Mount the data volumes in a new container:
|
|
Both volumes will be mounted under the root directory as /vol1
and /vol2
.
Multiple Data Volume Containers
Create and run multiple data volume containers:
|
|
Mount multiple data volume containers:
|
|
Now there are also two volumes mounted under the root directory as /vol1
and /vol2
, one from each container.
Multiple Data Volume Containers But Sharing the Same Data Volume Name
Create multiple data volume containers with the same data volume name /vol
:
|
|
Mount multiple data volume containers:
|
|
Well, it appears to be successful without any error. But there is only one shared data volume /vol
. The question is which container this data volume is from? To find out, we can create a file inside the data volume and then mount the data volume containers one at a time.
Create a file inside the shared data volume:
|
|
Mount data volume container vol1
:
|
|
Well, it is not in data volume container vol1
.
Mount data volume container vol2
:
|
|
It is in data volume container vol2
. Therefore, when mounting two data volume containers, if both share the same data volume name, later will override former, for example, in this command:
|
|
Data volume vol
from container vol2
will override the one from vol1
.