In a pod can we have a single volume for two different containers.
Can we use single Volume mount in Pod for more than a single container?
1k views Asked by Kishan Jr At
2
In a pod can we have a single volume for two different containers.
If you have two containers and you want to share data between them, you can do like below:
Here,
an
emptyDir
is used to share data in between two containers. Both containers has have volume.So, if you want to share same data, you can mount same volume in two containers.
But, if you want to use single volume, and do not want to share data between two containers, you can use
subPath
Here,
subPath
specify a sub-path inside the referenced volume instead of its root. That means, two separate directory from your volume will be mounted in two containers.In this example,
/vol
directory will be mounted incontainer1
container and/store
from volume will be mounted incontainer2
Now, you data will not be conflicted and shared