In this example, we directly instruct Docker to maintain a volume backed by NFS storage. Another way, of course, is to mount the NFS folder at the system level (afterwards, any container can bind-mount it).
By adding a Docker volume backed by NFS, Docker engine will take care of mounting/unmounting based on how containers are using this volume.
See also this comment:
Create the volume:
docker volume create -d "local" \
-o 'type=nfs' -o 'device=:/var/local/nfs/share' -o 'o=addr=nfs.example.net,rw,nfsvers=4,async' "nfs-share-1"
Use named volume in a container:
docker run -it --rm --mount "type=volume,source=nfs-share-1,target=/data" --name "test-1" debian:9 bash