World map

 

BM: Baca dalam Bahasa Melayu

World K4: Notes, Lockers & Packages

Scratch space: emptyDir

You will learn: to let two containers in one pod share files, and when those files vanish.

Checked with Kubernetes 1.37 on 31 Oct 2026

The problem

You are here: cluster kind-dev namespace default
kubectl get pods shows one prep pod with 2/2 containers Running. Terminal output: $ kubectl get pods NAME READY STATUS RESTARTS AGE prep-76f59ff49d-74h7k 2/2 Running 0 15s

One tray, two cooks. The cook chops onions. The helper fries them. Each works in a separate box. Where do they pass the onions?

Watch

Tap the line that makes the shared table.

0 of 1 found

An emptyDir: A scratch table on the tray: its containers share it, and it is wiped when the pod goes. is a scratch table on the tray. It starts empty. Both cooks mount it at /table, so they see the same files.

Try it

The cook puts onions on the table. Then the helper looks.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 1 (1 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen
  • prep·74h7k
dev-worker2Open

No trays here.

Time: +0s (sped up)

Predict

The tray is deleted. The Deployment makes a new one. What is on the new table?

Pick one answer.

Check

You are here: cluster kind-dev namespace default
The cook adds onions.txt. The pod is deleted and replaced. ls /table in the new pod prints nothing. Terminal output: $ kubectl exec deploy/prep -c cook -- touch /table/onions.txt $ kubectl delete pod prep-76f59ff49d-74h7k pod "prep-76f59ff49d-74h7k" deleted from default namespace $ kubectl rollout status deployment/prep --timeout=120s deployment "prep" successfully rolled out $ kubectl exec deploy/prep -c helper -- ls /table

ls prints nothing. The new tray got a new table. Scratch space only, never your orders.

Check

Do the onions stay or go?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now share scratch files between containers with emptyDir.

      Go deeper (optional)

      emptyDir: { medium: Memory } keeps the table in RAM. Fast, but its files count toward the container’s memory limit. sizeLimit caps the table. Good uses: a cache, or files a sidecar ships to a log service.

      Real rep (optional), on a practice cluster:

      Real mission

      1. kubectl apply -f prep.yaml
      2. kubectl exec deploy/prep -c cook -- touch /table/onions.txt
      3. kubectl exec deploy/prep -c helper -- ls /table
      4. kubectl delete -f prep.yaml

      0 of 5 steps done · Your ticks are saved.