A volume driver for NFS is required for a Swarm service.
AdvancedScenarioVolumes, storage and data
Answer
Situation read → Tasks can land on any node, so data must be reachable everywhere.
What I'd do → Use the built-in local driver with NFS options:
docker volume create --driver local \
--opt type=nfs --opt o=addr=10.0.0.5,rw,nfsvers=4 \
--opt device=:/exports/app shared-data
In a stack file define the volume with driver_opts.
Why → The mount happens on whichever node runs the task.
Interview tip → Mention that NFS adds latency and a single point of failure; databases should not live there without care.
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