NFS Native Support

** TL;DR I have a working solution below:NFS Native Support **

Hi there,

Has anyone successfully used the new NFS support in the latest D4M 8.03.0-ce-mac59 (23608)?

Is there specific documentation for how to get this working? I’ve been trying to get my container to sync with a directory on my mac. The OSX local filesystem is too slow for my Rails app.

I’ve tried a few things with docker-compose but I’m unsure what the IP address of the NFS server should be.

version: '2'
      - app-sync:/app:nocopy

      type: "nfs"
      o: "addr=,rw"
      device: ":/app"

I’ve had various errors regarding permissions, timeouts, and simply “invalid argument”.

Any advice would be greatly appreciated. Some kind of walkthrough would be amazing.


1 Like

Hi Sean,
I’m using NFS on mac and latest docker. I’m not certain if you want to do the nfs mount in docker or from mac and then bind-mount. I’m using the latter where I mount_nfs via mac terminal and then use -v option when running docker image. The only issue I found was that I couldn’t write to the nfs volume unless I chmod 777 the files (see an earlier post).

btw, where’s info on “new NFS support”? tia.

cheers, roy

Thanks Roy.

I’ve set an NFS share in /etc/exports but I’m not sure which IP/domain I should be using in the o string.

I’m struggling to find much info on native NFS support, sadly.

1 Like

I have a working solution.

Run this:

LINE="/Users -alldirs -mapall=$(id -u):$(id -g) localhost"
grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" | sudo tee -a $FILE

LINE="nfs.server.mount.require_resv_port = 0"
grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" | sudo tee -a $FILE > /dev/null

sudo nfsd restart

Now run docker-compose up using this:

version: '2'
      - "nfsmount:/app"

    driver: local
      type: nfs
      o: addr=addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3
      device: ":${PWD}"

This will mount the current directory (PWD) into /app inside the container.

Hi seanhandley.

I’ve try your solution but not working for me.

On my exports I have this : /Users -alldirs -mapall=501:20 localhost

And same than you on my docker-compose but I have permission denied when I up.

I used last version of docker for Mac.

Hi dak94

I’ve had similar feedback from other people also, yet it works fine on my machine (and my colleagues). There’s clearly something missing but it’s not clear what…

What do you see when you run this?

showmount -e

I see this :
Exports list on localhost:
/Users localhost

Ok, that looks fine.

Can you add this to /etc/nfs.conf ?

nfs.server.mount.require_resv_port = 0

Then run

sudo nfsd restart

and try docker-compose again?

1 Like

Yeah that’s work, thank’s.

Next step for me was to check if performance was better on my symfony app.

Thank’s for the help :wink:

Great! Happy to help.

And thanks for the feedback - now I know the missing conf is what’s breaking this for others.

Original solution updated to include nfs.conf changes.

Thanks! It is possible to have this working also with ?
Trying to mount the mysql data (/var/lib/mysql) inside the nfs volume but it gives me failed to chown errors :frowning:

Any suggestion?

Sorry, I’m not sure what you can do. This solution relies on mapping UID/GID to a known pair on OSX - as such this means you can’t chown files inside the container and expect the operation to succeed on the mounted directory.

There is an option called no_root_squash for NFS which you can add to /etc/exports but it seems the OSX version of NFS doesn’t support this feature.

I’m coming back after a few day of work with symfony and docker volume nfs and …
It was good for perf on display website.
It was not good for development.

A lot of time were I work I have to wait when I refresh website because they don’t have access to the file that I modify.

It was maybe a issue with the sync but for development, it’s annoying to wait after modify file, it’s a waste of time.

Conclusion, it’s a lot better but for web development with symfony it’s not good I must continue to use my VM with Debian and sync file with PhpStorm …

You can adjust the NFS options in your docker-compose yaml and see if you get better performance. The settings I landed on were trial and error with a Rails application. Check out the man pages for NFS options and see if tweaking them helps - remember you need to docker-compose down and docker volume prune -f between changes to the config.

Hi Sean,
your solution works for me thank you very much!
Just one question. Every time I reboot my Mac I need to execute a “sudo nfsd restart” before the “docker-compose up” to get it working properly. Does this happen to you?

I haven’t tested my plugin on the mac, but if you want to try it out

1 Like

Hi Manuele,

No, this doesn’t happen to me - but the containers I tend to test with aren’t brought up automatically so I suspect nfsd is already running before they start.

Even my containers aren’t brought up automatically and I already verified that nfsd is running before bringing them up (with a “ps aux | grep nfsd”). Anyway after a Mac boot, even if nfsd is running, I have to run “sudo nfsd restart” to have those containers working.
Thank you for feedback anyway!

How strange! Please let me know if you ever figure out why it’s happening.

It may be the same issue we have in Windows where there is a race condition of the share drive not connected yet before the containers start up. The docker managed plugins alleviate the issue by ensuring that they run BEFORE the containers.