Skip to content

Instantly share code, notes, and snippets.

@chiedo
Last active October 4, 2019 20:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chiedo/4d2cc894f53c3da1910c to your computer and use it in GitHub Desktop.
Save chiedo/4d2cc894f53c3da1910c to your computer and use it in GitHub Desktop.
Configuring boot2docker to use NFS on an OSX machine

Configuring Boot2Docker to use NFS on an OSX based machine

  • To improve the speed of Boot2Docker drastically, you will want to set it up to use NFS.

  • You will need to do the following once on your host machine:

    • Add this to /etc/exports on your mac

      # BOOT2-DOCKER-BEGIN
      /Users 192.168.59.103 -alldirs -mapall=501:20
      # BOOT2-DOCKER-END
      
    • Run this command on your host machine

      sudo nfsd restart

  • Then Start boot2docker and connect to the VM with ssh by doing the following:

    boot2docker up
    boot2docker ssh
    
  • Within boot2docker do the following

    • Open the the /var/lib/boot2docker/bootlocal.sh file for editing with the following command:

    sudo vi /var/lib/boot2docker/bootlocal.sh

    • Then add the following content to that script.

      #!/bin/sh
      sudo umount /Users
      sudo /usr/local/etc/init.d/nfs-client start
      sudo mount -t nfs -o rw --actimeo=2 192.168.59.3:/Users /Users
      
    • Then run the following

      sudo chmod +x /var/lib/boot2docker/bootlocal.sh
      
  • To test, restart boot2docker, confirm then run df to confirm. You should see something like the following:

    192.168.59.3:/Users     XG    XG    XG  X% /Users
    
  • You're all done. :)

@mattes
Copy link

mattes commented Apr 11, 2015

@chiedo
Copy link
Author

chiedo commented Apr 30, 2015

As a note to anyone who comes across this, the above script by @mattes is for docker-machine. I wrote a similar script for boot2docker specifically: https://github.com/chiedojohn/boot2docker/blob/c99263633ba84771bcba63bb6b99c3854fe65ea8/scripts/enable_nfs.rb

@zakariaboualaid
Copy link

Thank you for sharing this. The IP : 192.168.59.3, is referring to what? Thanks.

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