Kubernetes 101 : Sharing the "EMPTYDIR" volume between containers
"EMPTYDIR" is a type of kubernetes volumes that creates an empty directory on the pod's host to be mounted on the containers.
When the pod is removed, the directory is also removed.
We can share that storage space between two or more containers belonging to the same pod.
Below is the Yaml file of a a pod with two containers sharing an "EMPTYDIR" type of storage.
Both containers will have access to the "shared-data" pod's volume, mounted on the "/mountpoint1" and the "/mountpoint2" on the "container1" and the "container2" respectively.
In the below example, we create a file on "container1" in the "EMPTYDIR" volume, and we try to access it from "container2".
We start by creating a file in the "EMPYDIR" mounted on "/mountpoint1" in the "container1":
Then we try to see if we can access it from "/mountpoint2" on "container2":