An emptyDir volume provides temporary storage that starts empty, can be mounted into containers in the same pod, and disappears when the pod is deleted. It suits pod-local data rather than data that must survive pod replacement. section 4.2.2 section 7.4
Use emptyDir when the operational task requires:
- Sharing transient log data between a main application container and a sidecar container. section 4.2.2
- Providing temporary application data inside a pod without creating a persistent volume or claim. section 9.3.6
- Remembering that deleting the pod permanently deletes the volume's contents. section 4.2.2
Mount an emptyDir volume for log collection
Define the volume under spec.volumes and mount the same name in the container: volumes: [{name: logvol, emptyDir: {}}]; volumeMounts: [{mountPath: /var/log, name: logvol}]. Create it with kubectl create -f log-collector.yaml, then verify the pod with kubectl get po and inspect the mount using kubectl describe po log-collector. section 7.4
1 apiVersion: v1
2 kind: Pod
3 metadata:
4 creationTimestamp: null
5 labels:
6 run: log-collector
7 name: log-collector
8 spec:
9 containers:
10 - command:
11 - sleep
12 - "3600"
13 image: busybox
14 name: log-collector
15 resources: {}
16 volumeMounts:
17 - mountPath: /var/log
18 name: logvol
19 dnsPolicy: ClusterFirst
20 restartPolicy: Always
21 volumes:
22 - name: logvol
23 emptyDir: {}
Use the complete Pod manifest to check the required volume and volumeMount placement, names, and mount path. section 7.4


