CertGrid CertGrid
Hands-on Lab·Certified Kubernetes Administrator

Volumes: emptyDir and hostPath

Two containers share an emptyDir, then the Pod is deleted and the data is gone. A hostPath survives that, and is read back from the node's own filesystem, but the identical path on another node holds nothing at all.

Storage Guide 65 of 103 Beginner

Disk sizes are this lab's. The lifetime rules are properties of the volume types.

Two worker nodes are used deliberately, to show what hostPath does not give you.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

This guide includes

Use this when two containers in a Pod have to share files, or when something needs to reach the node's own filesystem. This matters because an emptyDir dies with the Pod and a hostPath is a different directory on every node - so neither is storage you can actually rely on.

Before you start

  1. emptyDir is how two containers share a filesystem

  2. Delete the Pod and the emptyDir goes with it

  3. hostPath writes to the node, and you can prove it

  4. The same hostPath on another node is a different directory

Official sources