Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfs share / guest to host #64

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

nfs share / guest to host #64

aheissenberger opened this issue Jan 9, 2014 · 100 comments
Labels

Comments

@aheissenberger
Copy link
Contributor

@aheissenberger aheissenberger commented Jan 9, 2014

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
Copy link
Contributor

@jpetazzo 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
Copy link
Contributor Author

@aheissenberger aheissenberger commented Jan 10, 2014

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

@jpetazzo
Copy link
Contributor

@jpetazzo jpetazzo commented Jan 10, 2014

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//issues/64#issuecomment-31993778
.

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

@aheissenberger
Copy link
Contributor Author

@aheissenberger aheissenberger commented Jan 10, 2014

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
Copy link
Contributor Author

@aheissenberger aheissenberger commented Jan 11, 2014

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
Copy link
Contributor Author

@aheissenberger aheissenberger commented Jan 13, 2014

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
Copy link
Contributor

@schickling schickling commented Jan 14, 2014

Thanks a ton for your efforts @aheissenberger !

@aheissenberger
Copy link
Contributor Author

@aheissenberger aheissenberger commented Jan 14, 2014

@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
Copy link
Contributor

@schickling schickling commented Jan 20, 2014

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

@kainz
Copy link

@kainz kainz commented Jan 21, 2014

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

@aheissenberger
Copy link
Contributor Author

@aheissenberger aheissenberger commented Jan 23, 2014

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
Copy link

@vincentbernat vincentbernat commented Jul 2, 2014

Will this eventually be merged to boot2docker?

@mitar
Copy link

@mitar mitar commented Jul 11, 2014

+1

2 similar comments
@sreuter
Copy link

@sreuter sreuter commented Jul 17, 2014

+1

@g12n
Copy link

@g12n g12n commented Jul 17, 2014

+1

@prologic
Copy link

@prologic prologic commented Aug 27, 2014

+!

@glung
Copy link

@glung glung commented Sep 10, 2014

+1

3 similar comments
@voxxit
Copy link

@voxxit voxxit commented Sep 11, 2014

+1

@joshgoebel
Copy link

@joshgoebel joshgoebel commented Oct 12, 2014

+1

@softprops
Copy link

@softprops softprops commented Oct 13, 2014

+1

@joshgoebel
Copy link

@joshgoebel joshgoebel 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
Copy link

@nicklinnell nicklinnell commented Oct 15, 2014

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

@squaresurf
Copy link

@squaresurf squaresurf commented May 7, 2015

@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
Copy link

@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
Copy link

@haggen haggen commented May 7, 2015

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

@phpguru
Copy link

@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
Copy link

@michaelfavia michaelfavia commented May 18, 2015

@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
Copy link

@brikis98 brikis98 commented May 18, 2015

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
Copy link

@olalonde olalonde commented May 21, 2015

@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
Copy link

@uptownhr uptownhr commented May 21, 2015

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

@squaresurf
Copy link

@squaresurf squaresurf commented May 22, 2015

@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
Copy link

@brikis98 brikis98 commented May 22, 2015

+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
Copy link
Contributor

@lmakarov lmakarov commented May 22, 2015

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
Copy link

@oliverguenther oliverguenther commented May 30, 2015

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
Copy link

@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
Copy link

@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
Copy link

@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.

@vincepri
Copy link

@vincepri vincepri commented Jun 23, 2015

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
Copy link

@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
Copy link

@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
Copy link

@ain ain commented Sep 1, 2015

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

@douglasmiranda
Copy link

@douglasmiranda douglasmiranda commented Sep 17, 2015

Has anyone tried this? https://github.com/adlogix/docker-machine-nfs

@squaresurf
Copy link

@squaresurf squaresurf commented Sep 18, 2015

@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
Copy link

@douglasmiranda douglasmiranda commented Sep 19, 2015

Just a feedback about docker-machine-nfs.

It works beautifully :D

@mikzalais
Copy link

@mikzalais mikzalais commented Sep 23, 2015

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.

@olalonde
Copy link

@olalonde olalonde commented Sep 30, 2015

@intellix
Copy link

@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
Copy link

@georgediaz88 georgediaz88 commented Oct 7, 2015

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.

@wglambert wglambert added the question label Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.