Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Example with nfs #10

Closed
tonivdv opened this issue Feb 17, 2015 · 31 comments
Closed

Example with nfs #10

tonivdv opened this issue Feb 17, 2015 · 31 comments

Comments

@tonivdv
Copy link

tonivdv commented Feb 17, 2015

Hey @dduportal ,

I was wondering if you could share a working Vagrantfile with NFS sharing. More specifically sharing the /Users directory (I'm on mac)

I was able to make it work with the version of https://github.com/YungSang/boot2docker-vagrant-box, however with this box I get permissions issues ... !?

Thanks

@tonivdv
Copy link
Author

tonivdv commented Feb 17, 2015

Hey @dduportal ,

After playing around a bit, I got it working by setting:

config.vm.synced_folder "/Users", "/Users", type: "nfs", mount_options: ["nolock", "vers=3", "udp"]
config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ["nolock", "vers=3", "udp"]

Is there any particular reason? Maybe this can be documented here?

@tonivdv tonivdv closed this as completed Feb 18, 2015
@dduportal dduportal reopened this Feb 18, 2015
@dduportal
Copy link
Owner

Hi @tonivdv !

Thanks you for pointing me out that fact. To be honest, I haven't tested well the NFS part (i rely on the PR submitted).

I you have a reproduction example, i'll try to reproduce and provide a setting or documentation inside the next version.

If you have and idea, or an envy to write some doc, it's open :)

@tonivdv
Copy link
Author

tonivdv commented Feb 18, 2015

Hey @dduportal ,

Well I can do that for sure. I'm currently very hard busy for a talk I have to do in 2 weeks. I've been able to tweak the vagrant file in order to have it seamlessly like if I was using boot2docker, except with much better performances.

Here's how my vagrant file looks like at the moment of this writing:

# Make sure same user and group as host is used
  config.nfs.map_uid = Process.uid   
  config.nfs.map_gid = Process.gid 

  config.vm.box = "dduportal/boot2docker"

  config.vm.network "private_network", ip: "192.168.10.10"

  config.vm.synced_folder "/Users", "/Users", type: "nfs", mount_options: ["nolock", "vers=3", "udp"]
  config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ["nolock", "vers=3", "udp"]

In awaiting better doc, this could maybe already help others.

@dduportal
Copy link
Owner

@tonivdv Thank you very much, no rush, take your time :)

@phpguru
Copy link

phpguru commented Feb 19, 2015

I have this in my Vagrantfile:

config.vm.network "private_network", ip: "192.168.33.20"
...
config.vm.synced_folder ".", Dir.pwd, type: "nfs", mount_options: ["nolock", "vers=3", "udp"]

It actually mounts fine (though on my colleague's MBP it doesn't work for some reason we have yet to determine) my LAMP/LNxMP apps need to chown & chmod lots of files in the nfs share, but instead of running like they did in boot2docker, instead of a normal startup, I get 1,000s of lines of chown operation not permitted on every file in my temp, cache & upload dirs.

I gave sudo vi /etc/exports a shot with (no_root_squash,async) at the end of the vagrant nfs mount config line but the file changes were overwritten upon vagrant up.

@tonivdv
Copy link
Author

tonivdv commented Feb 19, 2015

Hey @phpguru ,

Did you try with following too:

config.nfs.map_uid = Process.uid   
config.nfs.map_gid = Process.gid 

@dduportal
Copy link
Owner

OK, my thought are : if we push that default setting inside the baseball (there is a Vagrantfile inside), it should work on both Windows and Mac OS.
I'm not sure how to add a conditional part with Ruby inside the vagrant file.tpl file, but it should be doable.

@IbnSaeed
Copy link

When i run the above commands for nfs, i get the following error. Im running vagrant in Window 8.1 host.

config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid

config.vm.network "private_network", ip: "172.17.10.5"

config.vm.synced_folder "/Users", "/Users", type: "nfs", mount_options: ["nolock", "vers=3", "udp"]
config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ["nolock", "vers=3", "udp"]

==> default: Checking if box 'dduportal/boot2docker' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
    default: Adapter 3: hostonly
==> default: Forwarding ports...
    default: 2375 => 2375 (adapter 1)
    default: 2376 => 2376 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: docker
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions versions on your host (4.3.22) and guest (4.3.20 r96996) do not match.
The guest's platform is currently not supported, will try generic Linux method...
Copy iso file D:\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.22 - guest version is 4.3.20 r96996
mkdir: can't create directory '/tmp/selfgz84830606': No such file or directory
Cannot create target directory /tmp/selfgz84830606
You should try option --target OtherDirectory
An error occurred during installation of VirtualBox Guest Additions 4.3.22. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit nfs mounting file.
[NFS] Status: halted
[NFS] Start: started
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'nolock,vers=3,udp' 192.168.10.1:'/D/boot2docker' /vagrant

Stdout from the command:



Stderr from the command:

pmap_getmaps.c: rpc problem: RPC: Procedure unavailable
mount: RPC: Unable to receive; errno = Connection refused
mount: mounting 192.168.10.1:/D/boot2docker on /vagrant failed: Bad file descriptor

@dduportal
Copy link
Owner

Hello @IbnSaeed, by default, NFS does not work on Windows (see. Vagrant documentation - http://docs.vagrantup.com/v2/synced-folders/nfs.html ).

Maybe you should try with smb (http://docs.vagrantup.com/v2/synced-folders/smb.html) which should work with boot2docker (recent ones at least).

Or if NFS is absolutely needed, there is a vagrant plugin : https://github.com/GM-Alex/vagrant-winnfsd.

@IbnSaeed
Copy link

IbnSaeed commented Mar 1, 2015

@dduportal I am running the vagrant-winnfsd plugin.

It works when i run docker container with coreos + vagrant. But i get the above error when i try it with boot2docker.

@IbnSaeed
Copy link

IbnSaeed commented Mar 1, 2015

@dduportal Thanks for the smb link, ill take a look at it.

@IbnSaeed
Copy link

IbnSaeed commented Mar 1, 2015

@dduportal by the way, how is smb speed compared to nfs for bi-directional syncing ?

@dduportal
Copy link
Owner

Hi @IbnSaeed, @mitchellh, the creator of Vagrant, has published that post some times ago : http://mitchellh.com/comparing-filesystem-performance-in-virtual-machines around the sharing folder performances.

Briefly :

  • vboxsf (the default one) is the most portable and bi-directionnal, but also the worst in terms of performances.
  • SMB is THE bi-directional for Windows platforms (and Mac OS since this is the default sharing system since Mac OS 10.7). Not aimed to Linux (even if it can works), and can be a pain on the *** on Windows 7 (Powershell, admin rights on corporate systems...)
  • NFS, the bi-directional for Linux/Mac OS. Haven't used it, so i cannot talk on the usage. Ping @tonivdv @phpguru ?
  • Rsync : unidirectionnel but is universal, you need at least to install a rsync client on the host. On Windows i use Cswrsync (since its compatible with vagrant-cloudstack rsync, embed openSSH and does not need to install all the cygwin stuff which is quite heavy). The real power of rsync, is that it creates a "guest§native" folder : so no rights problems, no symbolics links, etc...

I personally use vboxsf as i need portability (i work on Mac OS and Windows and have a Debian-based GUI in a container).
When dealing on performances issues, i just use a docker data-container which will copy on one shot my files in a docker volume, achieving "guest-native performances".
The easier is the "dev workspace inside the VM + a SMB/CIFS/ container"

@ffung
Copy link

ffung commented Mar 5, 2015

I had to spent some time debugging why NFS didn't work, before I found this issue. Just wanted to mention that if you want to prevent the need for the nolock option, you can start the nfs-client in b2d. I think it's worth considering putting in, makes the usage of the box and NFS easier.

It's already installed and I think you can add to /opt/bootlocal.sh to start the nfs client with each boot.
/usr/local/etc/init.d/nfs-client start

@dduportal
Copy link
Owner

Thanks for the information @ffung !

I'm re-opening the issue to prepare a future PR (from myself or whoever is ready to do that :) ) that will add the nfs-client start inside the VM.

@dduportal dduportal reopened this Mar 5, 2015
@phpguru
Copy link

phpguru commented Mar 6, 2015

@tonivdv I missed your comment before and will try it. On another thread I saw the nix prog BindFS gets around the permissions issue but config option is preferred with less software if it works. I couldn't figure out how to install BindFS on tinycore. Really hopeful for an nfs solution! Thanks @dduportal!

@tonivdv
Copy link
Author

tonivdv commented Mar 6, 2015

@phpguru yeah I read about bindfs. I even looked at https://github.com/gael-ian/vagrant-bindfs where I did learn about map_uid and map_gid. When I saw it, I found it easier with those params. This config currently does work on all our macs :)

We still need to do the changes for making it work on Windows.

Once that is done, I'll be happy to write some Readme about this, which imho will be very helpful for new users.

@dduportal thx for the brief review on the sharing folders!

@dduportal
Copy link
Owner

OK, i'm trying to reproduce in order to add a bats tests that will describe the NFS share (at least /vagrant by default).

First try on 10.9.5 with vagrant 1.7.2 :

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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "dduportal/boot2docker"

  config.vm.synced_folder ".", "/vagrant", type: "nfs"
end
  • The start VM :
$ hackinthdedadou:ddu-b2d-nfs dadou$ vagrant up 
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'dduportal/boot2docker' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'dduportal/boot2docker'
    default: URL: https://vagrantcloud.com/dduportal/boot2docker
==> default: Adding box 'dduportal/boot2docker' (v1.5.0) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/dduportal/boxes/boot2docker/versions/1.5.0/providers/virtualbox.box
==> default: Successfully added box 'dduportal/boot2docker' (v1.5.0) for 'virtualbox'!
==> default: Importing base box 'dduportal/boot2docker'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'dduportal/boot2docker' is up to date...
==> default: Setting the name of the VM: ddu-b2d-nfs_default_1425741869439_27814
==> default: Couldn't find Cheffile at ./Cheffile.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 2375 => 2375 (adapter 1)
    default: 2376 => 2376 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: docker
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
Password:
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 192.168.10.1:'/Users/dadou/workspace/ddu-b2d-nfs' /vagrant

Stdout from the command:



Stderr from the command:

mount.nfs: an incorrect mount option was specified
mount: mounting 192.168.10.1:/Users/dadou/workspace/ddu-b2d-nfs on /vagrant failed: Connection refused
``

@tonivdv
Copy link
Author

tonivdv commented Mar 8, 2015

@dduportal I have the same issue when I remove the option 'nolock' option in the nfs mounting. Didn't try to understand why though ...

@phpguru
Copy link

phpguru commented Mar 16, 2015

Just started over from scratch. I'm really trying to switch from boot2docker to Vagrant but I keep running into various issues along the way. For instance, this time, now when I try to follow along, I get:

docker ps -a
FATA[0000] Error response from daemon: client and server don't have same version (client : 1.17, server: 1.16)
docker --version
Docker version 1.5.0, build a8a31ef

@thedug
Copy link

thedug commented Mar 16, 2015

Upgrade your local boot2docker

Douglas Ferguson
512-293-7279
Sent from my iPhone

On Mar 16, 2015, at 12:25 PM, Geoffrey Hoffman notifications@github.com wrote:

Just started over from scratch. I'm really trying to switch from boot2docker to Vagrant but I keep running into various issues along the way. For instance, this time, now when I try to follow along, I get:

docker ps -a
FATA[0000] Error response from daemon: client and server don't have same version (client : 1.17, server: 1.16)
docker --version
Docker version 1.5.0, build a8a31ef

Reply to this email directly or view it on GitHub.

@phpguru
Copy link

phpguru commented Mar 16, 2015

Thanks @thedug - I checked all my versions, and still get issues:

macpro:~ me$ boot2docker -v
Boot2Docker-cli version: v1.5.0
Git commit: ccd9032
macpro:dduportal me$ docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): darwin/amd64

I try again:

docker ps -a
FATA[0000] An error occurred trying to connect: Get https://localhost:2375/v1.17/containers/json?all=1: read tcp 127.0.0.1:2375: connection reset by peer 

I'm actually wondering if its VirtualBox...

@tonivdv
Copy link
Author

tonivdv commented Mar 16, 2015

Hey @phpguru ,

Did you update the environment variables correctly?

export DOCKER_HOST=tcp://127.0.0.1:2376
export DOCKER_CERT_PATH=/path/to/the/generated/tls
export DOCKER_TLS_VERIFY=1

I suggest you set this in your .profile or equivalent

@tonivdv
Copy link
Author

tonivdv commented Mar 16, 2015

And you don't have to keep boot2docker to use the docker client. You can download it and install through following:

curl -L -o docker https://get.docker.io/builds/Darwin/x86_64/docker-1.5.0
chmod +x docker
sudo mv docker /usr/local/bin/docker

But of course you can keep boot2docker but be sure to not mix ips and environment vars.

Hope it helps.

@dduportal
Copy link
Owner

Hi all, i implemented NFS default sharing, tested on Mac OS (Mavericks and Yosemite) : #17

The documentation has been updated.

The released box is the 1.6.1 : https://atlas.hashicorp.com/dduportal/boxes/boot2docker/versions/1.6.1

I've done a quick released since docker 1.6.2 is out.

If you have any feedback, please open a new Issue.

Thanks all for your help !

@tonivdv
Copy link
Author

tonivdv commented May 15, 2015

Thanks @dduportal 👍

@phpguru
Copy link

phpguru commented May 15, 2015

Hey @tonivdv, Up above you said export DOCKER_CERT_PATH=/path/to/the/generated/tls - what do you have for that value? Mine is still pointing to the old certs I was using for boot2docker ( e.g. export DOCKER_CERT_PATH=/Users/myusername/.boot2docker/certs/boot2docker-vm ) but I am convinced this is the only thing wrong with my config now. I opened an issue here but I am sure it is just that I'got wrong certs or not clear where the certs are generated for dduportal/boot2docker need to go or if they need to be regenerated.

@tonivdv
Copy link
Author

tonivdv commented May 17, 2015

@phpguru sorry couldn't respond sooner. But I see you figured it out 👍

@phpguru
Copy link

phpguru commented May 18, 2015

@tonivdv After stopping and re-starting the vagrant box, and doing a vagrant ssh the docker daemon started fine and recreated the certs. I then copied them to /vagrant/tls folder so the host could see them. It wasn't immediately clear, but after some fiddling I got it up and running fine. And magically, it's thousands of times faster than VBoxFS. The exporting and importing of container images forced me to increase the size of my virtualbox vm hard drive again. The speed this Docker solution offers is a Godsend for large projects. Thanks again @dduportal !! 👍

@tonivdv
Copy link
Author

tonivdv commented May 19, 2015

@phpguru yeah @dduportal did a great job of taking this project over, and especially maintaining it. I however try to get rid of vagrant and use docker-machine instead. We shared our script which activates nfs on docker-machine here https://github.com/adlogix/docker-machine-nfs. Though it could be that vagrant suits some projects better. But at least you know an alternative :)

@ehernandez-xk
Copy link

Hi everyone

Maybe one of you can help me with this issue #48

nfs simple example "failed:Connection refused"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants