Skip to content

Instantly share code, notes, and snippets.

@danlynn
Forked from ehazlett/gist:38ba224ae8bba348da2e
Last active August 14, 2016 03:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlynn/685873d328aef7df115a to your computer and use it in GitHub Desktop.
Save danlynn/685873d328aef7df115a to your computer and use it in GitHub Desktop.

NFS Server

OS X Host

Note: you will need sudo access. Add the following to /etc/exports replacing the myunixuser with your own unix user account name

/Users -alldirs -maproot=myunixuser -network 192.168.99.0 -mask 255.255.255.0

Restart NFS:

sudo nfsd restart

Linux Host

Note: you will need sudo access and NFS server (sudo apt-get install -y nfs-kernel-server on debian). Add the following to /etc/exports

/home 192.168.99.0/24(rw,no_root_squash,no_subtree_check)

Restart NFS

sudo systemctl restart nfs-kernel-server

Boot2Docker

You will need to remove the existing shared folder at /Users (only if on OS X). You can do this with (make sure the VM is stopped):

VBoxManage sharedfolder remove [vm-name] --name Users

Start the VM and ssh into it. Add the following to /var/lib/boot2docker/profile:

OS X Host

mkdir /Users
sudo mount -t nfs -o vers=3,nolock,udp 192.168.99.1:/Users /Users

Note that the 192.168.99.1 address is the IP of the host gateway - not the IP of the boot2docker machine. If using vmwarefusion then use 192.168.156.1 for the host gateway instead.

Linux Host

mkdir -p /mnt/home
mount -t nfs -o vers=3,nolock,udp 192.168.99.1:/home /mnt/home
for USERDIR in /mnt/home/*
do
    USER=`basename $USERDIR`
    ln -sf /mnt/home/$USER /home/$USER
done

Reboot the VM. You should now have NFS in b2d and be able to do things like:

docker run -v $(pwd):/dest/in/container ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment