In Kubernetes, an emptyDir is a simple ephemeral volume type that provides temporary storage to a pod during its lifetime. It is created when a pod is assigned to a node, and deleted when the pod is removed from that node.
This Pod creates a temporary volume mounted at /data, which is shared with the container.
You can choose where the data is stored:
| Medium | Description |
|---|---|
| (default) | Uses node's disk, SSD or network storage, depending on your environment |
Memory | Uses RAM (tmpfs) for faster access (but volatile) |
| Feature | Description |
|---|---|
| Starts empty | No data when created |
| Shared across containers | Same volume can be used by multiple containers in the pod |
| Deleted with pod | Volume is destroyed when the pod is removed |
| Node-local | Volume is stored on the node's local disk or memory |
| Fast | Ideal for performance-sensitive scratch space |
Caching intermediate build artifacts
Buffering logs
Temporary work directories
Sharing data between containers in the same pod (like sidecars)