A legacy app needs persistent state, but the team wants to scale it to 3 replicas.
AdvancedScenarioVolumes, storage and data
Answer
Situation read → Shared local state blocks horizontal scaling.
What I'd do →
- Identify what state it holds (sessions, uploads, cache).
- Move sessions to Redis, uploads to S3-compatible storage, DB state to a managed database.
- If state must stay on disk, use per-replica volumes (StatefulSet in Kubernetes) rather than a shared writable volume.
Why → A shared volume with several writers risks corruption and creates a single point of failure.
Interview tip → Externalizing state is the real fix, not a clever volume.
More on Volumes, storage and data
A Postgres container was removed and the data is gone. How should it have been run?BeginnerBind mount or named volume for local development of a Node app?BeginnerHow do you back up a named volume?IntermediateTwo containers must share files. What are your options?BeginnerA container needs a writable temp area but the root filesystem is read-only.IntermediateMoving a database volume from one Docker host to another.Intermediate