This issue is similar to one posted a couple of years ago but with a slight difference. I'm trying to identify how to spin up a Docker container which has an NFS Volume mount whether or not the NFS server is online.
I have a Docker volume that I have created from an NFS mount to a device which comes on and off the network at regular intervals:
docker volume create --driver local --opt type=nfs --opt o=addr=192.168.2.237,rw,soft,timeo=10,bg --opt device=:/media raspberryPi
In my mount options, I have intentionally specified a soft mount such that if the mount is not available, an error will return to the process running within the container and the application will handle the I/O error.
In theory, my setup works fine IFF the container is started when the NFS mount is present.
[eric@docker1 tmp]$ docker run --rm -it -v raspberryPi:/pi ubuntu bash
root@f8fd958740da:/# ls /pi
lost+found x y
If remove the device from the network, the NFS access fails from within the container (as expected):
root@f8fd958740da:/# ls /pi
ls: cannot access '/pi': Stale file handle
If I re-attach the device to the network, then the resource becomes available again, and everything continues to work.
The problem arises, however, if the NFS volume is NOT present at container start time. If it isn’t present, then the container fails to launch altogether:
[eric@docker1 tmp]$ docker run --rm -it -v raspberryPi:/pi ubuntu bash
docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/raspberryPi/_data': error while mounting volume with options: type='nfs' device=':/media/movies' o='addr=192.168.2.237,rw,soft,timeo=10': operation not supported.
Is there anyway I can configure docker to “ignore” the volume mount error and continue to mount it none-the-less? I tried using a background mount in the options, but that did not help. Essentially, I would like the container to launch with a mount configured to /pi even though the NFS Server is offline (similar to behaviour if the server is online and taken offline while the container is live).