How to Set Docker’s Default NFS Share Version to 4 or 4.2?

0
4
Asked By CuriousCat123 On

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

Answered By NFSMountMaster On

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?

Answered By NFSWizard77 On

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!

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.

Answered By TechGuru99 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.