# NFS Native Support

**URL:** <https://forums.docker.com/t/nfs-native-support/48531>\
**Category:** Docker Desktop\
**Tags:** macos\
**Created:** [March 27, 2018, 2:06pm UTC](https://forums.docker.com/t/nfs-native-support/48531 "2018-03-27T14:06:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [March 27, 2018, 2:06pm UTC](https://forums.docker.com/t/nfs-native-support/48531/1 "2018-03-27T14:06:45Z")

</div>

\*\* **TL;DR I have a working solution below:[NFS Native Support - #4 by seanhandley](https://forums.docker.com/t/nfs-native-support/48531/4)** \*\*

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'
services:
  api:
    volumes:
      - app-sync:/app:nocopy

volumes:
  app-sync:
    driver_opts:
      type: "nfs"
      o: "addr=172.18.0.4,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.

Cheers,  
Sean

---

<div class="post-metadata">

**Author:** ![rollinroy](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rollinroy](https://forums.docker.com/u/rollinroy)\
**Post date:** [March 27, 2018, 7:57pm UTC](https://forums.docker.com/t/nfs-native-support/48531/2 "2018-03-27T19:57:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [March 27, 2018, 9:08pm UTC](https://forums.docker.com/t/nfs-native-support/48531/3 "2018-03-27T21:08:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [March 28, 2018, 10:32pm UTC](https://forums.docker.com/t/nfs-native-support/48531/4 "2018-03-28T22:32:06Z")

</div>

I have a working solution.

Run this:

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

LINE="nfs.server.mount.require_resv_port = 0"
FILE=/etc/nfs.conf
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'
services:
  api:
    volumes:
      - "nfsmount:/app"

volumes:
  nfsmount:
    driver: local
    driver_opts:
      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.

---

<div class="post-metadata">

**Author:** ![dak94](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@dak94](https://forums.docker.com/u/dak94)\
**Post date:** [April 2, 2018, 9:30am UTC](https://forums.docker.com/t/nfs-native-support/48531/5 "2018-04-02T09:30:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [April 2, 2018, 10:04am UTC](https://forums.docker.com/t/nfs-native-support/48531/6 "2018-04-02T10:04:56Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![dak94](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@dak94](https://forums.docker.com/u/dak94)\
**Post date:** [April 2, 2018, 10:05am UTC](https://forums.docker.com/t/nfs-native-support/48531/7 "2018-04-02T10:05:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [April 2, 2018, 10:07am UTC](https://forums.docker.com/t/nfs-native-support/48531/8 "2018-04-02T10:07:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dak94](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@dak94](https://forums.docker.com/u/dak94)\
**Post date:** [April 2, 2018, 10:09am UTC](https://forums.docker.com/t/nfs-native-support/48531/9 "2018-04-02T10:09:41Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [April 2, 2018, 10:10am UTC](https://forums.docker.com/t/nfs-native-support/48531/10 "2018-04-02T10:10:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kianda](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/kianda/32/19442_2.png) [@kianda](https://forums.docker.com/u/kianda)\
**Post date:** [April 3, 2018, 7:34pm UTC](https://forums.docker.com/t/nfs-native-support/48531/11 "2018-04-03T19:34:06Z")

</div>

Thanks! It is possible to have this working also with [https://hub.docker.com/\_/mysql/](https://hub.docker.com/_/mysql/) ?  
Trying to mount the mysql data (/var/lib/mysql) inside the nfs volume but it gives me failed to chown errors ☹

Any suggestion?

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [April 4, 2018, 6:57am UTC](https://forums.docker.com/t/nfs-native-support/48531/12 "2018-04-04T06:57:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dak94](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@dak94](https://forums.docker.com/u/dak94)\
**Post date:** [April 26, 2018, 6:11pm UTC](https://forums.docker.com/t/nfs-native-support/48531/13 "2018-04-26T18:11:57Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [April 26, 2018, 6:30pm UTC](https://forums.docker.com/t/nfs-native-support/48531/14 "2018-04-26T18:30:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mmenozzi](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/mmenozzi/32/19751_2.png) [@mmenozzi](https://forums.docker.com/u/mmenozzi)\
**Post date:** [May 5, 2018, 1:12pm UTC](https://forums.docker.com/t/nfs-native-support/48531/15 "2018-05-05T13:12:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![trajano](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/trajano/32/16038_2.png) [@trajano](https://forums.docker.com/u/trajano)\
**Post date:** [May 6, 2018, 4:11pm UTC](https://forums.docker.com/t/nfs-native-support/48531/16 "2018-05-06T16:11:43Z")

</div>

I haven’t tested my plugin on the mac, but if you want to try it out [https://hub.docker.com/r/trajano/nfs-volume-plugin/](https://hub.docker.com/r/trajano/nfs-volume-plugin/)

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [May 8, 2018, 2:57pm UTC](https://forums.docker.com/t/nfs-native-support/48531/17 "2018-05-08T14:57:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mmenozzi](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/mmenozzi/32/19751_2.png) [@mmenozzi](https://forums.docker.com/u/mmenozzi)\
**Post date:** [May 9, 2018, 6:27am UTC](https://forums.docker.com/t/nfs-native-support/48531/18 "2018-05-09T06:27:27Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![seanhandley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/seanhandley/32/19360_2.png) [@seanhandley](https://forums.docker.com/u/seanhandley)\
**Post date:** [May 9, 2018, 9:37am UTC](https://forums.docker.com/t/nfs-native-support/48531/19 "2018-05-09T09:37:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![trajano](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/trajano/32/16038_2.png) [@trajano](https://forums.docker.com/u/trajano)\
**Post date:** [May 9, 2018, 3:38pm UTC](https://forums.docker.com/t/nfs-native-support/48531/20 "2018-05-09T15:38:00Z")

</div>

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.

[Next page](https://forums.docker.com/t/nfs-native-support/48531.md?page=2)
