Interview Prep/Docker/Volumes, storage and data

A container needs a writable temp area but the root filesystem is read-only.

IntermediateScenarioVolumes, storage and data
Answer

Situation read → --read-only is a hardening best practice but apps still write to /tmp and /run.

What I'd do →

docker run --read-only --tmpfs /tmp:rw,noexec,nosuid,size=64m \
  --tmpfs /run -v appdata:/var/lib/app myapp

Why → Writes land only in explicitly allowed places, and tmpfs is in memory so it vanishes on stop.

Interview tip → tmpfs counts against the container memory limit.

All Docker questions Roadmap: Docker & containers

More on Volumes, storage and data