Skip to content

Instantly share code, notes, and snippets.

@haggen
Last active September 11, 2018 03:19
Embed
What would you like to do?
boot2docker on nfs

Get boot2docker working with nfs instead of vboxsf.

Tested on:

- Boot2Docker-cli version: v1.6.0
  Git commit: 9894ae9
- Boot2Docker-cli version: v1.6.2
  Git commit: cb2c3bc

1) In your Mac, open the file /etc/nfs.conf and add this line:

nfs.server.mount.require_resv_port = 0

2) Then, open /etc/exports and add this line, changing the values to match your case:

/Users/<your username> -mapall=<your username>:staff <mac's ip address>

3) With both files changed time to apply the new settings:

sudo nfsd restart

4) Finally, ssh into your boot2docker machine and run:

sudo umount /Users
sudo mkdir /Users/<your username>
sudo /usr/local/etc/init.d/nfs-client start
sudo mount <mac's ip address>:/Users/<your username> /Users/<your username> -o async,noatime,actimeo=1,nolock,vers=3,udp

You'll notice I'm mounting an especific user's directory instead of the Users directory itself, that's because of permissions, I couldn't share the Users directory on my behalf.

@phpguru
Copy link

phpguru commented Apr 29, 2015

👍 Awesome... does this preserve permissions from the Mac across to the container?

@haggen
Copy link
Author

haggen commented Apr 29, 2015

@phpguru Not sure if it preservers all permissions, but giving a file +x on my Mac does work inside a docker container.

@rivetmichael
Copy link

hi @haggen, thanks for your help !! but it seems that it does not work on version :

Boot2Docker-cli version: v1.7.0
Git commit: 7d89508

I'm getting the following errors in /var/log/bootlocal.log =>
mount: 192.168.59.3:/Users/michael failed, reason given by server: Permission denied
mount: mounting 192.168.59.3:/Users/michael on /Users/michael failed: Bad file descriptor

I don't understand because i didn't set any auth on my NFS share.

Can you help me on this ? Thanks !

@silvamerica
Copy link

This is also not working in docker-machine 0.3.0 (which I believe uses boot2docker 1.7.0).

Copy link

ghost commented Jul 16, 2015

I had some permission issues mounting the nfs from bootdocker.
I solved it with this mod in /etc/exports on my Mac:
"/Users" -alldirs -mapall=[USERNAME]:staff -network 192.168.59.0 -mask 255.255.255.0
Force nfs restart (it needs few seconds):
mac$sudo nfsd restart
Check your NFS shares (if you got error, then wait for few seconds and rerun it):
mac$showmount -e

@eduardoleal
Copy link

Thanks for this!! 🙌 🙌 🙌

@iansmith
Copy link

Worked out of the box for me. Truly great work. 🏆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment