How to Set Docker's Default NFS Share Version to 4 or 4.2?
Asked by
CuriousCat123
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.
Answers
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.
Reply to this answer
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!
Reply to this answer
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?
Reply to this answer
Add your answer
Answers are reviewed before publication.
QuickFixXpert: For sure, that's a solid approach! Iโm in a similar boat, needing to use 4.2 for the `xattr` functionality as well.