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
emptyDir
volume namedmy-volume
in the pod template - The pod has only one container
- The
emptyDir
volume is mounted on/data
directory of the container - The container writes some data in the
my-temp-data.txt
file 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
/data
directory is present in the container: -
View the content of
/data/my-temp-data.txt
file:
Clean Up¶
Assuming your folder structure looks like the one below:
Let's delete all the resources we created: