An emptyDir volume gives containers in the same Pod a shared directory backed by the node’s boot disk. Kubernetes creates it empty, keeps its data across container restarts, and removes the data when the Pod is deleted, rescheduled, moved, or the node becomes unhealthy. Use it for temporary data rather than long-term storage. section 9.1.1
Use emptyDir when the data has short-lived operational value:
- Share files between containers in one Pod. section 9.1.1
- Preserve an on-disk cache across restarts of an individual container. section 9.1.1
- Let an init container prepare configuration for a main container without using persistent storage. section 9.2.2
- Avoid emptyDir for data that must survive Pod rescheduling; use persistent storage instead. section 9.1.1 section 9.2.2
Mounting an emptyDir cache
Define a volume with `emptyDir: {}` and mount it into a container, such as at `/app/cache/`. Multiple containers in the Pod can mount the same named volume. In a Redis StatefulSet, an init container instead copies either a primary or replica configuration from a ConfigMap into an emptyDir mount, which the Redis container then reads. section 9.2.2


