Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using NFS with boot2docker

NFS Server

OS X Host

Note: you will need sudo access. Add the following to /etc/exports

/Users -alldirs -maproot=root:wheel -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 stopeed):

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

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