Two containers must share files. What are your options?
BeginnerScenarioVolumes, storage and data
Answer
Situation read → Typical for a web server serving files generated by an app.
What I'd do →
- A shared named volume mounted in both (
-v assets:/srv/assets, read-only in the consumer). --volumes-from producerfor a quick link.- For cross-host, NFS volume driver or object storage instead.
Why → Volumes avoid host path dependency; use :ro where possible.
Interview tip → Concurrent writers need app-level locking; Docker does not provide it.
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?IntermediateA container needs a writable temp area but the root filesystem is read-only.IntermediateMoving a database volume from one Docker host to another.IntermediateExplain how copy-on-write affects performance of a write-heavy container.Advanced