dduportal / boot2docker-vagrant-box

Packer scripts to build a Vagrant-compatible boot2docker box.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nfs simple example "failed: Connection refused"

ehernandez-xk opened this issue · comments

commented

I have posted my question in stackoverflow related to fns and the message failed: Bad file descriptor vagrant-and-docker-nfs-failed-bad-file-descriptor Using Vagrant and Docker as a provider.

So I decided to test a sample example posted by @dduportal #10 (comment)

And after vagrant up, the execution hangs for a while and finally it shows an error

This is the output

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'dduportal/boot2docker'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'dduportal/boot2docker' is up to date...
==> default: A newer version of the box 'dduportal/boot2docker' is available! You currently
==> default: have version '1.10.1'. The latest is version '1.11.1'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: ex2_default_1463056322815_57229
==> default: Fixed port collision for 2375 => 2375. Now on port 2200.
==> default: Fixed port collision for 2376 => 2376. Now on port 2201.
==> default: Fixed port collision for 22 => 2222. Now on port 2202.
==> 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 (guest) => 2200 (host) (adapter 1)
    default: 2376 (guest) => 2201 (host) (adapter 1)
    default: 22 (guest) => 2202 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2202
    default: SSH username: docker
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. 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...
==> default: Mounting NFS shared folders...

The error:

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/it/workspace/docker-vagrant/ex2' /vagrant

Stdout from the command:

Stderr from the command:

mount.nfs: an incorrect mount option was specified
mount: mounting 192.168.10.1:/Users/it/workspace/docker-vagrant/ex2 on /vagrant failed: Connection refused

I Previously installed (I don't know if was necessary)

  • OSXFuse 2-8.3 (downloading the dmg file)
  • nfts-3g (using brew install homebrew/fuse/ntfs-3g)

I'm used:

  • Mac Yosemite 10.10.5
  • Vagrant 1.8.1
  • dduportal/boot2docker (virtualbox, 1.10.1)

Hello @ehernandez-xk !

You're lucky, I'm just having a bit of time ongoing to solve few Github issues :)

1st try on my way (same Vagrant, latest box, on 10.11.4), stuck during NFS mounting. Strange since the tests passed.

I'm going to debug.

On your side, you can help by trying to uninstall Fuse and ntfs-3g (=> NTFS <> NFS :) ), and try again, posting here your results.

Thanks !

commented

Hi @dduportal, I'm very lucky so =0)

I already uninstall Fuse and ntfs-3g without errors. (I restarted my Mac)
This time the execution requested me my password, and then I'm waiting to the output log, is taking a long time.

Password:
==> default: Mounting NFS shared folders...

I'm going to paste it when the console shows the output.

commented

It looks like there are no timeout, I still waiting

commented

VAGRANT_LOG=info vagrant up

....

==> default: Mounting NFS shared folders...
 INFO ssh: SSH is ready!
 INFO ssh: Execute:  (sudo=false)
 INFO guest: Execute capability: mount_nfs_folder [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "192.168.10.1", {"nfs-sync"=>{:type=>:nfs, :mount_options=>["nolock", "vers=3", "udp"], :id=>"nfs-sync", :guestpath=>"/Users/it/workspace/docker-vagrant/ex2", :hostpath=>"/Users/it/workspace/docker-vagrant/ex2", :disabled=>false, :__vagrantfile=>true, :map_uid=>502, :map_gid=>20, :nfs_udp=>true, :nfs_version=>3, :uuid=>"703144856"}, "/vagrant"=>{:type=>:nfs, :guestpath=>"/vagrant", :hostpath=>"/Users/it/workspace/docker-vagrant/ex2", :disabled=>false, :__vagrantfile=>true, :map_uid=>502, :map_gid=>20, :nfs_udp=>true, :nfs_version=>3, :uuid=>"703144856"}}] (tinycore)
 INFO ssh: SSH is ready!
 INFO ssh: Execute:  (sudo=false)
 INFO guest: Execute capability: shell_expand_guest_path [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "/Users/it/workspace/docker-vagrant/ex2"] (tinycore)
 INFO ssh: Execute: echo; printf /Users/it/workspace/docker-vagrant/ex2 (sudo=false)
 INFO ssh: Execute: mkdir -p /Users/it/workspace/docker-vagrant/ex2 (sudo=true)
 INFO ssh: Execute: mount -o 'nolock,vers=3,udp' 192.168.10.1:'/Users/it/workspace/docker-vagrant/ex2' /Users/it/workspace/docker-vagrant/ex2 (sudo=true)
 INFO retryable: Retryable exception raised: #<Vagrant::Errors::LinuxNFSMountFailed: 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:'/Users/it/workspace/docker-vagrant/ex2' /Users/it/workspace/docker-vagrant/ex2

Stdout from the command:



Stderr from the command:

mount: RPC: Unable to receive; errno = Connection refused
mount: mounting 192.168.10.1:/Users/it/workspace/docker-vagrant/ex2 on /Users/it/workspace/docker-vagrant/ex2 failed: Bad file descriptor
>
 INFO ssh: Execute: mount -o 'nolock,vers=3,udp' 192.168.10.1:'/Users/it/workspace/docker-vagrant/ex2' /Users/it/workspace/docker-vagrant/ex2 (sudo=true)
 INFO retryable: Retryable exception raised: #<Vagrant::Errors::LinuxNFSMountFailed: 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:'/Users/it/workspace/docker-vagrant/ex2' /Users/it/workspace/docker-vagrant/ex2

Stdout from the command:



Stderr from the command:

mount: RPC: Unable to receive; errno = Connection refused
mount: mounting 192.168.10.1:/Users/it/workspace/docker-vagrant/ex2 on /Users/it/workspace/docker-vagrant/ex2 failed: Bad file descriptor
>
 INFO ssh: Execute: mount -o 'nolock,vers=3,udp' 192.168.10.1:'/Users/it/workspace/docker-vagrant/ex2' /Users/it/workspace/docker-vagrant/ex2 (sudo=true)
 INFO ssh: Execute: if command -v /sbin/init &>/dev/null && /sbin/init --version | grep upstart &>/dev/null; then
  /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT='/Users/it/workspace/docker-vagrant/ex2'
fi
 (sudo=true)
 INFO ssh: SSH is ready!
 INFO ssh: Execute:  (sudo=false)
 INFO guest: Execute capability: shell_expand_guest_path [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "/vagrant"] (tinycore)
 INFO ssh: Execute: echo; printf /vagrant (sudo=false)
 INFO ssh: Execute: mkdir -p /vagrant (sudo=true)
 INFO ssh: Execute: mount -o 'vers=3,udp' 192.168.10.1:'/Users/it/workspace/docker-vagrant/ex2' /vagrant (sudo=true)

commented

Hey,
using config.vm.box_version="1.6.1" works well for this simple example. so that menas something changes in the newer versions.

But in my project shows the error:

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/it/workspace/docker-vagrant/docker-provisioning' /project

Stdout from the command:

Stderr from the command:

mount.nfs: an incorrect mount option was specified
mount: mounting 192.168.10.1:/Users/it/workspace/docker-vagrant/docker-provisioning on /project failed: Connection refused

the password is not requested.
Any idea?

commented

I forgot the variable, sorry
export B2D_NFS_SYNC=1

So it looks like with 1.6.1 works fine.

onfig.vm.synced_folder ".", "/vagrant", type: "nfs"

With the following folder shows the error failed: Connection refused

onfig.vm.synced_folder ".", "/project", type: "nfs"

Temporally I will use this version 1.6.1

OK, I found the problem: latest version of boot2docker does not have anymore the nfs-client started.

Short term solution for you, create this script and vagrant reload, it works fine then, until vagrant destroy -f:

$ vagrant ssh -c "cat /var/lib/boot2docker/bootlocal.sh"
#!/bin/sh

/usr/local/etc/init.d/nfs-client start

I'm working on:

  • Why my test harness did not catch that
  • Implementing and releasing a new 1.11.1 box.
commented

I like your approach, This can be run in the provision phase? or is to late for that?

I will wait to the new release =0)

many thanks

OK, my bad, I needed to sleep when trying to reproduce :)

In fact, you don't have anything to configure within your Vagrantflie, regarding NFS.

The test done by the harness suite juste do this (from doc. https://github.com/dduportal/boot2docker-vagrant-box#tips--tricks ):

$ export B2D_NFS_SYNC=1
$ vagrant up

Step for you:

  • Destroy your VM with vagrant destroy -f
  • Edit your Vagrantfile and remove the lines config.vm.synced_folder containing `type: nfs'
  • Export the above env var B2D_NFS_SYNC
  • vagrant up : it works again.

=> Technical explanation:

I'm not very pleased of my work since you should be able to enable this within the Vagrantgfile also. I'm thinking about implementing a Ruby variable as flags to check within your Vagrantfile, or applying some logic that will detect if you have mount points over NFS and add the nolock options. Don't know yet.

Can you please confirm that it is working now ?

Thanks to having taken time to send me feedback and debug logs !

commented

Tks man. take a rest!

When the B2D_NFS_SYNC is enabled. the default sync is using "." the current directory, buy in my case I need to go back in the directories. "../" because my docker host Vagrantfile lives in dockerHost directory.

so I decided to copy your config

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

And works fine.

Is that ok?

Thats is perfect !

I propose you to contribute to the documentation ?
You just have, on your web-browser, to fork the repository, edit the README.md, save and push the pull request.

Thanks for the feedbacks !

commented

Sure! I will