nfs share / guest to host #64

Open
aheissenberger opened this Issue Jan 9, 2014 · 100 comments

Projects

None yet
@aheissenberger
Contributor

I have allready added nfs-utilities to the ISO but have some troubles to forward the nfs ports to osx.

/etc/sysconfig/nfs:
RQUOTAD_PORT=875
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
STATD_PORT=662

this plus 111 TCP/UDP, 2049 TCP/UDP are forwarded by virtual box to local host.

I have no problem to mount the share local inside the vm but mounting the share from OSX gives me:

sudo mount -o resvport,vers=3 127.0.0.1:'/var/lib/docker/share' '/Users/ah/tmp/mnt'
mount_nfs: can't mount /var/lib/docker/share from 127.0.0.1 onto /Users/ah/tmp/mnt: No such file or directory
@jpetazzo
Contributor
jpetazzo commented Jan 9, 2014

Did you consider using the 9p filesystem?
It just requires a TCP connection (no portmapper etc.) and is dead simple to setup on the server side.
See https://gist.github.com/jpetazzo/5668338 for an example (that has to be adapted of course, since the example involves containers).

@aheissenberger
Contributor

I have not found a 9p Server/Client for OSX

@jpetazzo
Contributor

Argh, I thought that diod might be available for OSX.
It should be straightforward to compile, but I never tried that (I don't
use OSX). :-(

On Thu, Jan 9, 2014 at 4:54 PM, aheissenberger notifications@github.comwrote:

I have not found a 9p Server/Client for OSX


Reply to this email directly or view it on GitHubhttps://github.com/steeve/boot2docker/issues/64#issuecomment-31993778
.

@jpetazzo https://twitter.com/jpetazzo
Latest blog post: http://jpetazzo.github.io/2013/12/07/pxe-netboot-docker/

@aheissenberger
Contributor

I have go it working:

  1. I am using a host only network on eth1
  2. exporting a share from OSX does work
  3. exporting a share from docker vm works

open problems:

  1. exporting a share from OS only works if security is set to no - which I only can set with "NFS Manager" - not able to get this configuration in my /etc/exports config:
    /Users/ah/SVN-Checkouts/DEV/dev -network 192.168.56.0 -mask 255.255.255.0

You can find a working new boot2docker which adds the hostonly adaper and the ISO which include the nfs utilities here:
https://github.com/aheissenberger/boot2docker

do not forget to start the nfs client or server inside the VM:
sudo /usr/local/etc/init.d/nfs-server start
sudo /usr/local/etc/init.d/nfs-client start

@aheissenberger
Contributor

Here is the patch to use it - but the code is not finally cleaned up and you need to rebuid the ISO:
https://github.com/aheissenberger/boot2docker/tree/feature/shared-folder-nfs

@aheissenberger
Contributor

Here is the link to the bug preventing tiny core to support NAT and hostonly in a VM:
https://bugs.busybox.net/show_bug.cgi?id=6788

my code above contains the fix already

@schickling
Member

Thanks a ton for your efforts @aheissenberger !

@aheissenberger
Contributor

@schickling the existing code in in my repository creates an ISO with nfs support but at the moment you have to manuel mount the shares.

@steeve would be nice if the docker remote client could tell the daemon to handle the mounting if the hostpath contains an IP - e.g:
docker run -v 192.168.56.1:/var/logs:/var/host_logs:ro ubuntu bash

@schickling
Member

@aheissenberger Will you open a PR with your NFS settings? :shipit:

@kainz
kainz commented Jan 21, 2014

I made diod work in OSX, see #89, and https://github.com/kainz/diod.

@aheissenberger
Contributor

Finished - sharing a directory from the host to a container in a VM works:

boot2docker cmd run -d -p 8081:80 -name webserver -v ~/SVN-Checkouts/DEV/dev:/app tutum/apache-php /run.sh

the CMD option will magically convert the input to docker run -d -p 0.0.0.0::80 -name webserver -v /var/lib/docker/share/809218c9bf1bdfa803dfedb65ef0de83:/app tutum/apache-php /run.sh and will mount the directory and will set the port forwarding #104 .

mount 192.168.56.1:/Users/franz/SVN-Checkouts/DEV/dev /var/lib/docker/share/809218c9bf1bdfa803dfedb65ef0de83
VBoxManage controlvm boot2docker-vm natpf1 zfp8081,tcp,127.0.0.1,8081,0.0.0.0,49154

It expects/User/franz/SVN-Checkouts/ to be exported by the NFS-server on the host

$ cat /etc/exports
/Users/franz/SVN-Checkouts -alldirs -ro -network 192.168.56.0 -mask 255.255.255.0

You will need my ISO with NFS installed, 2nd host only interface and my ./boot2docker script with the ./boot2docker cmd option
https://github.com/aheissenberger/boot2docker

ToDO:
[ ] more testing
[ ] there is no clean up of the mounted volums after the container gets stopped

@vincentbernat

Will this eventually be merged to boot2docker?

@mitar
mitar commented Jul 11, 2014

+1

@sreuter
sreuter commented Jul 17, 2014

+1

@g12n
g12n commented Jul 17, 2014

+1

@prologic

+!

@glung
glung commented Sep 10, 2014

+1

@voxxit
voxxit commented Sep 11, 2014

+1

@yyyc514
yyyc514 commented Oct 12, 2014

+1

@softprops

+1

@yyyc514
yyyc514 commented Oct 13, 2014

It looks like all the pieces are actually there to setup this us semi-manually:

  • add NFS exports on Mac OS X
  • add a post-boot script to boot2docker that mounts shares (however many you want) to project locations on the VM... I'm thinking of something like /projects/a /projects/b, etc... then when setting up volumes you map the /projects/* locations into your dockers as you want to.

The post-boot script will insure the shares are mounted should you restart boot2docker. I'll add additional details when I set this up later.

@nicklinnell

I've been trying to get an export on my mac host to mount on the boot2docker vm without much luck so far. This is what I have done:

  • Added /Users/username -alldirs -mapall=501:20 -network 192.168.56.0 -mask 255.255.255.0 to /etc/exports and restarted nfsd
  • Started /usr/local/etc/init.d/nfs-client on the boot2docker vm

When I try and mount my share I get the following:

docker@boot2docker:/etc$ sudo mount 192.168.1.204:/Users/username /home/docker/shared
mount: RPC: Authentication error; why = Client credential too weak
mount: mounting 192.168.1.204:/Users/username on /home/docker/shared failed: Bad file descriptor

I'm missing something I guess but I'm not sure what and Google is not being my friend today

@glung
glung commented Oct 20, 2014

https://blog.docker.com/2014/10/docker-1-3-signed-images-process-injection-security-options-mac-shared-directories/

Using Docker on Mac OS X has become much easier since we incorporated boot2docker, but the experience has had some usability quirks. With this release we are addressing the most common issue: sharing directories between your Mac and your containers. Using Docker 1.3 with the corresponding version of boot2docker, host-mounted volumes now work the way you expect them to.

To make debugging easier, we’re introducing docker exec, which allows a user to spawn a
process inside their Docker container via the Docker API and CLI. For example…

$ docker exec -it ubuntu_bash bash

…will create a new Bash session inside the container ubuntu_bash.

@nicklinnell

@lungos how are you finding the speed of these shares? They are working great in that they connect and I have access to the host's directory from the container but for me it is just too slow when accessing Rails applications (possibly the large amount of small files issue others have reported). I used to use docker-osx and mount the shared via nfs which worked very well hence why I'm trying to get nfs working with boot2docker.

For me being able to mount my host's nfs shares in the boot2docker vm would be a real benefit

@glung
glung commented Oct 20, 2014

@nicklinnell I did not get a change to test.

@getvega
getvega commented Oct 20, 2014

@nicklinnell +1
vboxsf mounted folders are still way too slow compared to nfs
cf http://mitchellh.com/comparing-filesystem-performance-in-virtual-machines

@afillatre

@nicklinnell +1 as well
Like other people, my benchmark shows that performance is up to 10 times worst when files are on a VirtualBox shared folder. I was very excited about the v1.3 and being able to mount the folders I needed, but I realise now that I get the same performance issues I had with the samba mounts before.

Anyway, a simple tutorial on how to use NFS shared folders instead on Mac OSX and Windows would be nice, even if this is not automated yet.

@jmreicha

@afillatre same here. Volume mounting works perfectly but the performance is horrible.

It would be nice if there was some way to specify NFS or vbox shared folders.

@SvenDowideit
Member

see the boot2docker-cli repo - there's a PR that someone can pick up and help with :)

@jmreicha

Okay thanks I will have a look and see if I can help.

@clifton
clifton commented Nov 20, 2014

👍 boot2docker/fig is working great for small projects but projects with a large number of small files (as other have reported above) is still too slow. Would it be possible to use NFS by default?

@rawkode
rawkode commented Nov 20, 2014

👍 for NFS/rsync/anything else that will increase performance. Current mounts are just unworkable for large projects (Symfony2 application here)

@pikeas
pikeas commented Nov 28, 2014

Can someone share a quick explanation of how to set up better filesharing (NFS) under boot2docker?

@ora726
ora726 commented Dec 3, 2014

A notice in the doc on the performance/restrictions of host shared folders would be nice. I spent 2 days struggling to get this to work (Access rights using a non root user in the guest) and when finally all my problems where solved I hit this really bad performance problem. Performance are so bad that 50% of the time building a MEAN.io environment will partially fail. starting the mean.io stack can take over a minute. in comparison the same process on a guest local folder work like charm. Anybody wanting to find a better alternative or knowing how to speed up the shares has my unconditional support :-)

@kainz
kainz commented Dec 3, 2014

While this sounds hilariously overdone -- if its source and the like, you may have better luck running a gogs.io server and having your build pull from that? I was working on setting up a functional diod-on-OSX<->boot2docker setup a ways back, but I no longer have (easy) access to an OSX machine, so my copy/port of that repo is bitrotting I am afraid. You could try cloning/building it from github.com/kainz/diod and then try out something like the process I used from https://github.com/kainz/boot2docker/blob/linux-3.13-9pfs/README.osx-plus-diod.

Those instructions are almost a year out of date now though, so it would be an adventure if you go down that road.

For me, personally, I moved most of my workflow over to dockerfile repos that had git submodules to dodge even having to deal with NFS and/or shared folders. My current workflow is dokku/12factoring everything. I like the idea of the 9pfs folder sharing, but other options turned out to be less hassle for more performance.

@clifton
clifton commented Dec 3, 2014

Right on @kainz, thanks for the info. boot2docker works fantastic for prepacked/built images. It just struggles when trying to load apps for development mode. Figuring out how to make the dev environment have a quick feedback loop (in large projects with many small files) is one of the biggest unsolved problems IMO.

@thaJeztah thaJeztah referenced this issue in boot2docker/boot2docker-cli Dec 25, 2014
Closed

Seems to be very slow for volumes with many (>= 10k) files #329

@Pindar
Pindar commented Jan 11, 2015

👍

@phpguru
phpguru commented Jan 20, 2015

Has anyone tried this? I'm wanting to attempt to use an NFS share instead of vboxsf to see if it solves the slowness issues with boot2docker.

See Benchmarks.

@clifton
clifton commented Jan 20, 2015

My team has been using a vagrant managed version of the Parallels boot2docker image and have had reasonably good performance aside from asset compilation, which we're moving to a faster auto-recompile system outside of Rails.

cc @hadronzoo @caseywebdev

Example Vagrantfile with SSH agent forwarding, etc (written by @hadronzoo)

VAGRANTFILE_API_VERSION = '2'
Vagrant.require_version '>= 1.6.3'

def require_plugin(name)
  unless Vagrant.has_plugin?(name)
    raise <<-EOT.strip
      #{name} plugin required. Please run: "vagrant plugin install #{name}"
    EOT
  end
end

require_plugin 'vagrant-parallels'
require_plugin 'vagrant-triggers'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define 'boot2docker'
  config.vm.box = 'parallels/boot2docker'

  config.vm.provider 'parallels' do |v|
    v.name = 'boot2docker'
    v.check_guest_tools = false
    v.memory = (`sysctl -n hw.memsize`).to_i / 2**20 * 2 / 3 / 4 * 4
    v.cpus = (`sysctl -n hw.ncpu`).to_i * 2 / 3
    v.optimize_power_consumption = false
    v.customize ['set', :id, '--device-add', 'hdd']
  end

  config.vm.network 'private_network', ip: '10.109.20.70'

  config.ssh.forward_agent = true

  {
       80 =>    80  # web
       # ... other ports
  }.each do |guest, host|
    config.vm.network :forwarded_port, guest: guest, host: host
  end

  config.vm.synced_folder(
    ENV['HOME'], ENV['HOME'],
    type: 'nfs',
    nfs_udp: true,
    mount_options: %w[actimeo=2],
    bsd__nfs_options: %w[alldirs maproot=root:wheel]
  )

  # fix busybox/udhcpc issue
  config.vm.provision :shell do |s|
    s.inline = <<-EOT
      if ! grep -qs ^nameserver /etc/resolv.conf; then
        sudo /sbin/udhcpc
      fi
      cat /etc/resolv.conf
    EOT
  end

  # adjust datetime after suspend and resume
  config.vm.provision :shell do |s|
    s.inline = <<-EOT
      sudo /usr/local/bin/ntpclient -s -h pool.ntp.org
      date
    EOT
  end

  # ssh connection for agent forwarding
  config.trigger.after [:up, :reload] do
    command = %Q(vagrant ssh -- -t 'ln -sf `ls -d /tmp/ssh*/* | head -n 1` /tmp/authsock; sh')
    pid = Process.spawn(command, out: '/dev/null', err: '/dev/null')
    Process.detach(pid)
  end
end
@andyshinn

@phpguru I use yungsang/boot2docker and yungsang/coreos boxes with Vagrant for the NFS support. They work well and give useable performance for local Rails app development on Mac with Docker.

@hadronzoo

In that Vagrantfile, v.customize ['set', :id, '--device-add', 'hdd'] should be changed to the following to avoid duplicate disk creation:

unless `prlctl list --info boot2docker | grep hdd0`
  v.customize ['set', :id, '--device-add', 'hdd']
end
@rogerrogers

Does anyone here know if there is a plan for boot2docker to get other host<->container file share options that will improve performance on a Mac? I was trying to move to Docker for Drupal development work, but the performance is just too slow using boot2docker, and setting up the Vagrant approach described above kinda nixes my hope that anyone in our team could simply fig up a project.

Just a query, I know the Docker team are going non-stop.

@lmakarov
lmakarov commented Feb 6, 2015

@eerkel I achieved some good results with this box: yungsang/boot2docker

Running docker that way is no different from using boot2docker.
Instead of boot2docker start you do vagrant up.
The rest is the same, except you now have complete control over the docker VM and can switch to using NFS shares instead of vboxfs, etc.

What you eventually get is this:

  • Your project dir exported as an NFS share => Vbox/Vagrant VM mounts the NFS share => docker maps the folder via volumes in a container.
  • your dev tools access files natively on your Mac
  • performance is much better than with vboxs

I did some testing with different combinations of folder sharing options - installing plain Drupal 7 standard profile with drush: time drush si standard -y
For that particular test case Docker via Boot2docker w/ NFS performs as good as VBox VM w/ NFS and just a tiny bit slower than VBox VM w/rsync.

Here's the Vagrantfile gist that kicked things off for me with yungsang/boot2docker and NFS. Specifically the following:

  # Mount current dir under same path in VM
  config.vm.synced_folder ".", Dir.pwd, type: "nfs", mount_options: ["nolock", "vers=3", "udp"]

That's what makes things transparent for docker running in a VM to mount volumes from the host.

@Jupiterrr

Currently I'm using a small shell script on OS X that wraps rsync to mount/copy the files into the vm. This works quite well for me with my rails app.
Maybe this is helpful to anyone.
https://gist.github.com/Jupiterrr/5348f7f95df7de2888f0

@rogerrogers

@lmakarov Your post was encouraging enough for me to give it a shot. I've got this working and can confirm the performance is blazing fast compared to the boot2docker approach.

I was getting page load speeds of ~5-10 seconds with boot2docker and now it's effectively instantaneous. I mention because I initially thought the performance issues may be due to running the Drupal site within a VM, but the networking appears to have been the culprit.

Anyone else wanting to run an app with 10k+ files, which is pretty common for a Drupal site, you should use Vagrant with NFS as @lmakarov suggests.

@benjy
benjy commented Feb 9, 2015

Yes I can confirm the Vagrant approach using NFS is the way to go. No performance issues at all for me.

@Pindar
Pindar commented Feb 9, 2015

@andyshinn thank you for mentioning. I switched to the CoreOS vagrant box and it's much better.

@lmakarov
lmakarov commented Feb 9, 2015

@andyshinn, @Pindar is there any difference in performance (or anything else) between the two images (yungsang/boot2docker and yungsang/coreos)?
I did not try yungsang/coreos since it had an older Docker version than yungsang/boot2docker.
Do you have different use cases for them?

@andyshinn

The biggest difference for me is btrfs vs aufs for the underlying filesystem. The CoreOS version issue was raised at YungSang/coreos-packer#5. But you can also force CoreOS to update with update_engine_client -update.

@uptownhr

So why isn't NFS the default? Is there a reason?

@lmakarov

@uptownhr NFS will only work for Mac. vboxfs while terribly slow is cross-platform and more reliable (?)

@zkanda
zkanda commented Mar 20, 2015

I wonder what's taking this too long, can't we just use the same strategy that vagrant is using?

@prologic

@zkanda same strategy as Vagrant? What would that be? AFAIK Vagrant supports different types of "synced folders". rsync, virtualbox shared folders, nfs, etc. There is no "strategy" as such :)

@zkanda
zkanda commented Mar 20, 2015

@prologic Well I'm sorry if that's not clear for you, what I'm saying is to support different types of "synced folders".
E.g.
OSX/Linux - NFS/Rsync.
SMB - Windows.

Something like boot2docker up --sync_type=nfs
or a config in ~/.boot2docker

@prologic

@zkanda Ahh :) So not "strategy" -- You want configurable "sync folder" mechanisms :)

+1 I guess :)

@rawkode
rawkode commented Mar 20, 2015

@prologic one would argue that giving people the choice to use the tools that work in their environment is definitely a strategy - arguably the most important strategy.

The sad part is this issue has been here a year and we've all had to conjure up our own way a of making Docker work for our development environments

@prologic

I agree - If you don't have native Docker (Linux Desktop) this makes it all very hard :)

@blueimp
blueimp commented Mar 31, 2015

I also ran into performance issues when sharing host directories with many files.

I've released my boot2docker Vagrant Box for Parallels implementation which might be useful to some.
It's similar to the NFS based versions released by other users, but fixes some path handling issues (it works with folders containing spaces or quotes) and tries to emulate the ease of use of the official setup.

@olalonde

Until boot2docker offers this functionality natively, I wrote this script that sets up both local OS X nfs server config and boot2docker nfs client: http://syskall.com/using-boot2docker-using-nfs-instead-of-vboxsf/ Hope it's useful to someone else.

@ryl
ryl commented Apr 16, 2015

Just ran into the slow performance problem on a mac. Like a few of the others here I'm doing development on a Drupal site and seeing really slow performance on file operations. For me using boot2docker and docker-compose is preferable to using vagrant, so it would be wonderful to have some means of using NFS.

@leighmcculloch

I'm seeing lag issues too, avoided NFS because several people have had issues getting it to work, and am instead using fswatch and unison to do fast automatic two-way sync. I've wrapped this up in a volume container: leighmcculloch/docker-unison to make it plug-and-play, and it allowed me to keep a normal boot2docker setup without using vagrant. Can't wait for NFS to come out though, boot2docker with NFS + Docker Compose will be a great dev environment.

@Ninir
Ninir commented Apr 20, 2015

@tianon @SvenDowideit Hey guys, do you plan to do something for NFS Sharings like overridable option or parameter, or so... ?

Thanks!

@atbaker atbaker referenced this issue in excellalabs/excella-retro Apr 24, 2015
Closed

Adds Docker support #48

@haggen
haggen commented Apr 29, 2015

@olalonde Hey nice script, but when I ran it, I got this from boot2docker machine:

mount: RPC: Authentication error; why = Client credential too weak
mount: mounting 192.168.1.34:/Users/Arthur on /Users/Arthur failed: Bad file descriptor

Looking around I read that it has to do with what ports are being mapped, but that's too far for me, any ideas ?

@olalonde

@haggen Oh, I remember having seen that message at some point when writing the script. Could you copy/paste the full log and the output on cat /etc/exports (on OS X) would also help.

@haggen
haggen commented Apr 29, 2015

Hey @olalonde thanks anyway, but I got it working! The missing bit was a nfs configuration in /etc/nfs.conf on my Mac.

I made a gist for the whole process that worked for me: https://gist.github.com/haggen/f84f55e3ed2c9c930335

@olalonde

@haggen Oh thanks for documenting that. I'll see if I can update my script.

@brikis98
brikis98 commented May 7, 2015

I tried using NFS as @olalonde and @haggen suggested, but it made no difference in performance. I tried Vagrant + NFS as @lmakarov suggested, and it was still slow. I tried the unison file system as leighmcculloch suggested, but hit strange connection errors.

At it is, Boot2Docker, Docker, and OS X seem unusable for development. If anyone has other ideas to try, I created a StackOverflow thread to try to gather possible answers.

@squaresurf

I've found my apps to be an order of a magnitude quicker using NFS with a Vagrant wrapper.

@zkanda
zkanda commented May 7, 2015

Here's an interesting project: https://github.com/codekitchen/dinghy

I tested it myself and works pretty well.
Though it doesn't support < OSX 10.10

@brikis98
brikis98 commented May 7, 2015

@squaresurf: how did you set it up?
@zkanda: thanks for the pointer, I'll check that out.

@squaresurf

@zkanda I like the look of that.

@brikis98 here is an example Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure('2') do |config|
  config.vm.box = 'spartan/docker'
  config.vm.provider 'virtualbox' do |vb|
    vb.memory = 2048
  end

  config.vm.network 'private_network', ip: '10.10.10.10'

  config.vm.synced_folder '.', '/vagrant', type: 'nfs'

  # Provision the box with the bin/vagrant_provision script.
  config.vm.provision 'shell', path: 'bin/vagrant_provision'
end

The provisioner: bin/vagrant_provision

#!/bin/sh

# Install needed packages
apt-get update;
apt-get install -y ntp;

# Set it up to cd to /vagrant on login.
profile='/home/vagrant/.profile';
if [ "$(tail -n 1 $profile)" != 'cd /vagrant' ]; then
    echo 'cd /vagrant' >> $profile;
fi

cd /vagrant;

# Build the boxes
docker-compose build;

# Set up the database.
docker-compose up -d db;
sleep 5;

docker-compose run --rm web bundle exec rake db:setup;

docker-compose stop db;

Simple script to start it all up: bin/up

#!/bin/sh

vagrant up
vagrant ssh -c "docker-compose up --no-recreate"
@brikis98
brikis98 commented May 7, 2015

@zkanda: I just tried out dinghy and it's an improvement. Instead of a mounted folder being 10x or 15x slower, it's now only 2-3x slower. It's almost usable, but not quite.

Also, it doesn't solve the file system watcher issue. For example, with jekyll serve --watch --force_polling, file changes are only picked up ~30 seconds after they happen.

@squaresurf: Thanks. I'll mess around with Vagrant next and see if I can get anything good out of it.

@squaresurf

@brikis98 you shouldn't get more speed out of my setup than dinghy. I actually just switched to using dinghy since it makes interfacing with docker so much easier. It is as fast if not faster than my vagrant solution above.

@zkanda thanks again for sharing dinghy with us.

@brikis98
brikis98 commented May 7, 2015

OK, I may have finally found a solution that actually makes me productive: vagrant + rsync. It's a bit of a pain to setup, so I've captured the details in this StackOverflow answer. If I find something even better, I'll update that answer.

@haggen
haggen commented May 7, 2015

Hey, I just would like to thank you all for the amazing work! ;D Have a nice day.

@zkanda zkanda referenced this issue in archen/django-tests May 11, 2015
Open

Dockerize Django tests #5

@phpguru
phpguru commented May 15, 2015

You guys should check out @dduportal's boot2docker-vagrant-box - as of v1.6 it has NFS built in, default.

@michaelfavia

@brikis98: Consider adding a couple mount options to improve NFS file share performance. I use these in other vagrant boxes to great effect:

config.vm.synced_folder ".", "/home/vagrant/project", :nfs => true, :mount_options => ['nolock,vers=3,udp,noatime,actimeo=1']

YMMV. Good luck!

@brikis98

Thanks @michaelfavia, I'll play around with those.

BTW, in the meantime, I've packaged my Vagrant + Rsync solution for being productive with Docker on OS X as an open source project called docker-osx-dev.

@olalonde

@haggen Just updated the script (it adds nfs.server.mount.require_resv_port = 0 to /etc/nfs.conf now if its not set already) https://gist.github.com/olalonde/3f7512c0bd2bc8abb46d#file-boot2docker-use-nfs-sh-L39. Should work now.

@uptownhr

wish someone could make a one liner, copy and paste to get this done.

@squaresurf

@uptownhr I think dingy is the closest you'll get:
brew install https://github.com/codekitchen/dinghy/raw/latest/dinghy.rb

Dingy replaces boot2docker btw.

@brikis98

+1 for @squaresurf's comment. If you want to use NFS, dinghy is the easiest way to set it up. If you want to use rsync, which I've found to be much faster than NFS (albeit one-way only), check out docker-osx-dev.

@lmakarov

And if you want versatility and portability, check-out https://github.com/blinkreaction/boot2docker-vagrant
This project aims to provide equally good support forth both Mac (via nfs, rsync) and Windows (via smb, "smb2", rsync).

@oliverguenther

Thanks for all your effort in the various workarounds that spawned around slow vboxsf performance.
I've attempted to summarize the current state in workarounds in a single place here. I'm working on a performance evaluation of these variants.

That being said, I currently employ a custom Vagrant box with NFS mapping (similar to the box by blinkreaction) and am satisfied with the performance. I've also tried rsync and while it is noticeably faster, I am dependent on two-way synchronization between host and container for various reasons.

@chouclee
chouclee commented Jun 9, 2015

@olalonde Thanks for your script.
Have you seen any improvement using NFS? What is your benchmark?
I used Docker to deploy a Tomcat webapp located in host's folder, but I couldn't see any improvement using NFS. Host would use about 12s to deploy, docker would use 45-120s(usually 60s) with vboxsf, and 32-120s with NFS (usually 60s).

@olalonde
olalonde commented Jun 9, 2015

@chouclee to be honest, I can't say I paid much attention to that. The primary reason I'm using NFS is that LevelDB refuses to work with vboxsf. I'd be curious to see some benchmark as well though and optimise the script if possible.

@chouclee
chouclee commented Jun 9, 2015

@olalonde Ah, I see. I'm curious because most people say NFS could be 1.3-2x slower than rsync which is almost as fast as native. Anyway, thanks for sharing the script.

@vinceprignano

I am using https://github.com/dduportal/boot2docker-vagrant-box that seems to fix all the crazy issues I was having with boot2docker. I am not sure why Vagrant + NFS is much faster that NFS on official boot2docker though.

I set it up making it on the same IP address of boot2docker and using the same certs path.

@heyyoyo
heyyoyo commented Jul 4, 2015

Anyone achieved success to mount a Windows NFS folder from boot2docker vm with the NFS Windows server WinNFSd ?
I'm using this version : https://bitbucket.org/yannschepens/winnfsd-new

After starting the nfs-client,
Everytime I tried to mount my Windows folder I have this error:

pmap_getmaps.c: rpc problem: RPC: Procedure unavailable
mount: RPC: Unable to receive; errno = Connection refused
mount: mounting 10.0.0.1:/c/web on /var/www failed: Bad file descriptor

But I could see WinNFSd is seeing the request because it logs:
PORTMAP NOTIMP

@heyyoyo
heyyoyo commented Jul 5, 2015

I replaced winnfsd by HanWIN nfs server and now it works as expected. It's strange winnfsd was working with vagrant and regular ubuntu. The nfs client is probably different

@ain
ain commented Sep 1, 2015

👍 for a consistent fix. It's a killer for the whole concept, esp. on large projects.

@squaresurf

@douglasmiranda, that looks like the future. I'm gonna give it a shot here soon.

I like that it doesn't try to replace docker-machine so you get the benefits of the latest development on docker-machine. Which is why I had to stop using dinghy. I needed to use the latest version of docker, but dinghy was behind.

@douglasmiranda

Just a feedback about docker-machine-nfs.

It works beautifully :D

@mikzalais

I've got issue with boot2docker box when trying this.
If will not connect to my nfs share. In fact it was not able to ping the host after it was restarted. It was able to ping 192.168.99.1 only at first boot up after machine is created. After restarting it was not, although it was accessing internet ok.
Update to latest 1.8.2a of docker-toolbox was the same.

@intellix
intellix commented Oct 4, 2015

Damn, docker-machine-nfs was easily the best solution. Tried docker-osx-dev but it didn't really install correctly. docker-machine-nfs was a one command thing and it's an instant fix

@georgediaz88

same here. Already loving docker-machine-nfs just because I can naturally use and feel comfortable with docker-machine vs what some of these other tools do.

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