a lot of my containers depend on data that exist on NFS shares. So when restarting the machine, if the docker service starts before all the NFS shares have been mounted, the containers cannot start.
so I need a way to mount all the NFS shares before starting the docker service. So I modified this file
Why are you even trying to mount your nfs shares uing systemd, rather the /etc/fstab? I never had a timing problem with mounts in /etc/fstab - except stale connections from time to time.
Because of the stale connections, I moved over to use a nfs volume, declared in my compose file:
But I am using /etc/fstab to mount the NFS share. Still, the docker service starts before /etc/fstab manages to mount the NFS share. So I just login on the machine run systemctl restart docker and everything is fine.
I also tried your suggestion to mount the share as an NFS volume in docker, like this
docker volume create --driver local --opt type=nfs --opt o=addr=192.168.1.29,rw --opt device=:/media media
and the volume is created under /var/lib/docker/volumes but it’s empty. Shouldn’t it contain the files I have in my NFS share? (\192.168.1.29\media)
Odd that you are having problems with mount in /etc/fstab. Never had any problems (except the stale share ofcourse) when I rebooted the machines after a couple of months.
If no container using that volume is started, you will only see the metadata file opts.json, which holds the details to mount the remote share. Once a container using that volume is started, you should see the content in the _data subfolder.