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

Comments

Projects
None yet
@aheissenberger
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@jpetazzo

jpetazzo Jan 9, 2014

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@aheissenberger

aheissenberger Jan 10, 2014

Contributor

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

Contributor

aheissenberger commented Jan 10, 2014

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

@jpetazzo

This comment has been minimized.

Show comment
Hide comment
@jpetazzo

jpetazzo Jan 10, 2014

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/

Contributor

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/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

This comment has been minimized.

Show comment
Hide comment
@aheissenberger

aheissenberger Jan 10, 2014

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@aheissenberger

aheissenberger Jan 11, 2014

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@aheissenberger

aheissenberger Jan 13, 2014

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@schickling

schickling Jan 14, 2014

Contributor

Thanks a ton for your efforts @aheissenberger !

Contributor

schickling commented Jan 14, 2014

Thanks a ton for your efforts @aheissenberger !

@aheissenberger

This comment has been minimized.

Show comment
Hide comment
@aheissenberger

aheissenberger Jan 14, 2014

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@schickling

schickling Jan 20, 2014

Contributor

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

Contributor

schickling commented Jan 20, 2014

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

@kainz

This comment has been minimized.

Show comment
Hide comment
@kainz

kainz Jan 21, 2014

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

kainz commented Jan 21, 2014

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

@aheissenberger

This comment has been minimized.

Show comment
Hide comment
@aheissenberger

aheissenberger Jan 23, 2014

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@vincentbernat

vincentbernat Jul 2, 2014

Will this eventually be merged to boot2docker?

vincentbernat commented Jul 2, 2014

Will this eventually be merged to boot2docker?

@mitar

This comment has been minimized.

Show comment
Hide comment
@mitar

mitar commented Jul 11, 2014

+1

@sreuter

This comment has been minimized.

Show comment
Hide comment
@sreuter

sreuter commented Jul 17, 2014

+1

@g12n

This comment has been minimized.

Show comment
Hide comment
@g12n

g12n commented Jul 17, 2014

+1

@prologic

This comment has been minimized.

Show comment
Hide comment
@prologic

prologic commented Aug 27, 2014

+!

@glung

This comment has been minimized.

Show comment
Hide comment
@glung

glung commented Sep 10, 2014

+1

@voxxit

This comment has been minimized.

Show comment
Hide comment
@voxxit

voxxit commented Sep 11, 2014

+1

@yyyc514

This comment has been minimized.

Show comment
Hide comment
@yyyc514

yyyc514 commented Oct 12, 2014

+1

@softprops

This comment has been minimized.

Show comment
Hide comment
@softprops

softprops commented Oct 13, 2014

+1

@yyyc514

This comment has been minimized.

Show comment
Hide comment
@yyyc514

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

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

This comment has been minimized.

Show comment
Hide comment
@nicklinnell

nicklinnell 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

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

@glung

This comment has been minimized.

Show comment
Hide comment
@glung

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

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

This comment has been minimized.

Show comment
Hide comment
@nicklinnell

nicklinnell Oct 20, 2014

@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

nicklinnell commented Oct 20, 2014

@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

This comment has been minimized.

Show comment
Hide comment
@glung

glung Oct 20, 2014

@nicklinnell I did not get a change to test.

glung commented Oct 20, 2014

@nicklinnell I did not get a change to test.

@getvega

This comment has been minimized.

Show comment
Hide comment
@getvega

getvega 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

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

@Jupiterrr

This comment has been minimized.

Show comment
Hide comment

Jupiterrr commented Oct 23, 2014

@afillatre

This comment has been minimized.

Show comment
Hide comment
@afillatre

afillatre Oct 24, 2014

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

afillatre commented Oct 24, 2014

@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

This comment has been minimized.

Show comment
Hide comment
@jmreicha

jmreicha Oct 25, 2014

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

jmreicha commented Oct 25, 2014

@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

This comment has been minimized.

Show comment
Hide comment
@SvenDowideit

SvenDowideit Oct 26, 2014

Contributor

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

Contributor

SvenDowideit commented Oct 26, 2014

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

@jmreicha

This comment has been minimized.

Show comment
Hide comment
@jmreicha

jmreicha Oct 27, 2014

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

jmreicha commented Oct 27, 2014

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

@haggen

This comment has been minimized.

Show comment
Hide comment
@haggen

haggen 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 ?

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

This comment has been minimized.

Show comment
Hide comment
@olalonde

olalonde Apr 29, 2015

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

olalonde commented Apr 29, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@haggen

haggen 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

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

This comment has been minimized.

Show comment
Hide comment
@olalonde

olalonde Apr 29, 2015

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

olalonde commented Apr 29, 2015

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

@brikis98

This comment has been minimized.

Show comment
Hide comment
@brikis98

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

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

This comment has been minimized.

Show comment
Hide comment
@squaresurf

squaresurf May 7, 2015

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

squaresurf commented May 7, 2015

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

@zkanda

This comment has been minimized.

Show comment
Hide comment
@zkanda

zkanda 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

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

This comment has been minimized.

Show comment
Hide comment
@brikis98

brikis98 May 7, 2015

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

brikis98 commented May 7, 2015

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

@squaresurf

This comment has been minimized.

Show comment
Hide comment
@squaresurf

squaresurf May 7, 2015

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

squaresurf commented May 7, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@brikis98

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

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

This comment has been minimized.

Show comment
Hide comment
@squaresurf

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

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

This comment has been minimized.

Show comment
Hide comment
@brikis98

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

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

This comment has been minimized.

Show comment
Hide comment
@haggen

haggen May 7, 2015

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

haggen commented May 7, 2015

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

@phpguru

This comment has been minimized.

Show comment
Hide comment
@phpguru

phpguru May 15, 2015

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

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

This comment has been minimized.

Show comment
Hide comment
@michaelfavia

michaelfavia 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!

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

This comment has been minimized.

Show comment
Hide comment
@brikis98

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

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

This comment has been minimized.

Show comment
Hide comment
@olalonde

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

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

This comment has been minimized.

Show comment
Hide comment
@uptownhr

uptownhr May 21, 2015

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

uptownhr commented May 21, 2015

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

@squaresurf

This comment has been minimized.

Show comment
Hide comment
@squaresurf

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

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

This comment has been minimized.

Show comment
Hide comment
@brikis98

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

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

This comment has been minimized.

Show comment
Hide comment
@lmakarov

lmakarov May 22, 2015

Contributor

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

Contributor

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

@olalonde

This comment has been minimized.

Show comment
Hide comment
@oliverguenther

This comment has been minimized.

Show comment
Hide comment
@oliverguenther

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

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

This comment has been minimized.

Show comment
Hide comment
@chouclee

chouclee 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).

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

This comment has been minimized.

Show comment
Hide comment
@olalonde

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

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

This comment has been minimized.

Show comment
Hide comment
@chouclee

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

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

This comment has been minimized.

Show comment
Hide comment
@vincepri

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

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

This comment has been minimized.

Show comment
Hide comment
@heyyoyo

heyyoyo 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 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

This comment has been minimized.

Show comment
Hide comment
@heyyoyo

heyyoyo 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

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

This comment has been minimized.

Show comment
Hide comment
@ain

ain Sep 1, 2015

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

ain commented Sep 1, 2015

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

@douglasmiranda

This comment has been minimized.

Show comment
Hide comment

douglasmiranda commented Sep 17, 2015

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

@squaresurf

This comment has been minimized.

Show comment
Hide comment
@squaresurf

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

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

This comment has been minimized.

Show comment
Hide comment
@douglasmiranda

douglasmiranda Sep 19, 2015

Just a feedback about docker-machine-nfs.

It works beautifully :D

douglasmiranda commented Sep 19, 2015

Just a feedback about docker-machine-nfs.

It works beautifully :D

@mikzalais

This comment has been minimized.

Show comment
Hide comment
@mikzalais

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

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

This comment has been minimized.

Show comment
Hide comment
@intellix

This comment has been minimized.

Show comment
Hide comment
@intellix

intellix 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

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

This comment has been minimized.

Show comment
Hide comment
@georgediaz88

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

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