I've been having some trouble getting a Docker service up and running that requires `xattr`s. It seems to me (although I haven't verified it) that even if my host mounts NFS volumes with version 4 by default, Docker (along with Docker Compose and Portainer) defaults to mounting with version 3. Is there any way to change this default NFS mount version to 4 or even 4.2? I'm using Fedora CoreOS / uBlue, and adjusting this would save me from having to specify the version for every single NFS mount.
3 Answers
I usually mount the NFS directly onto the virtual machine that's running the Docker containers. Is it better to handle the mounting within the compose file instead?
I always add something like this in my compose file:
```
volumes:
irisdata:
driver: local
driver_opts:
type: nfs
o: "addr=10.10.10.10,nfsvers=4"
device: ":/home/w453y/mydata"
```
This way, I ensure I’m using version 4 when needed. Just a heads up, if you need `xattr` support, you’ll have to explicitly set it to 4.2. Also, remember to add `,soft,nolock`; otherwise, if the NFS gets stuck, it could hang your entire Docker setup!
The options you provide to Docker are what's sent to the kernel when mounting. Docker doesn't really modify this much, aside from resolving hostnames. So, unfortunately, you can’t change the default behavior unless you're willing to dive into patching the kernel NFS module.
For sure, that's a solid approach! I’m in a similar boat, needing to use 4.2 for the `xattr` functionality as well.