I host various docker containers on my Ubuntu 18 machine. A few of them require storing their data on my Synology NAS. At first, I was using the host machine's
/etc/fstab to control NFS mounts, which I then mounted in the containers (as a mount, not a volume).
However, I figured it would be a better idea to have the containers map NFS to mount points in the containers. The host really has no use for the mounts, so it didn't make sense to maintain them there.
At the moment, I am configuring my NFS volumes like this (using Docker Compose v3 format):
ERROR Rendering Code Block
This works great when the NAS is booted and working normally. However, I had a power outage and noticed all sorts of problems. Also, the timing of which machines boot first (NAS vs Ubuntu box) affects reliability of my docker container volumes. In my last situation, the NAS was not powered on. So when the container was started, it failed:
ERROR: for app Cannot start service app: error while mounting volume '/var/lib/docker/volumes/nextcloud_data/_data': error while mounting volume with options: type='nfs' device=':/volume2/nextcloud' o='addr=192.168.1.51,nolock,soft,rw': no route to host
What would be nice is if docker would keep retrying to mount the volume until the NAS was powered on again. That would make this hands-free and prevent any timing issues (on which devices boot first across the network) from causing permanent failures like this.
I'm also not sure what happens if a volume is created, and the NAS is powered off at any point. Does the volume stay available? Does docker keep trying to reconnect the NFS mount? I feel like there is very little control here.
Note I just use Docker Compose. I don't use Swarm for technical reasons I won't go into here. Can someone recommend a way to resolve these reliability issues? Are NFS volumes in Docker the way to go? Should I go back to mounting on the host? Is there an amazing 3rd option out there somewhere?
Intuition is to suggest that mounting on the host is better, for the sake on controlling runorder where nfsd may be failing while NAS is unavailable. My sense of it is that asking containers to phone home where they won't have any telemetry into the state of the filesystem share is just architecturally a dogfight.. Did you resolve this issue finally? I'm running into a similar situation where I am want to get my container launched even if my NFS server is down. @EricB. No sadly. I haven't revisited this in quite a while (since I posted, actually). I am still using a NFS mount on my host OS and I just do a standard volume mount from that to my docker container.