emptyDir Volume Demo¶
Let's see how we can use emptyDir volume as temporary storage.
Here is the Docker Image used in this tutorial: reyanshkharga/nginx
Step 1: Create a Deployment With emptyDir Volume¶
Let's create a deployment as follows:
Observe the following:
- We have added an
emptyDirvolume namedmy-volumein the pod template - The pod has only one container
- The
emptyDirvolume is mounted on/datadirectory of the container - The container writes some data in the
my-temp-data.txtfile every 5 seconds
Apply the manifest to create the deployment:
Step 2: Verify Deployment and Pods¶
Step 3: Verify Volume Mount and Data¶
Let's verify if the emptyDir volume was mounted in the container.
-
Start a shell session inside the container:
-
Verify if
/datadirectory is present in the container: -
View the content of
/data/my-temp-data.txtfile:
Clean Up¶
Assuming your folder structure looks like the one below:
Let's delete all the resources we created: