Search code examples
macosvagrantboot2dockernfsvagrantfile

Vagrant and Docker nfs failed: Bad file descriptor


After a lot of review trying to use rsync in Vagrant with Docker as provider. (bidirectional sync) I moved on to use nfs to sync my files inside the VM boot2docker

I have this vagrant error message after vagrant up

dockerhost: 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.50.1:'/Users/myMac/workspace/docker-vagrant/test' /project

Stdout from the command:

Stderr from the command:

mount: RPC: Unable to receive; errno = No route to host
mount: mounting 192.168.50.1:/Users/myMac/workspace/docker-vagrant/test on /project failed: Bad file descriptor

Vagrantfile

Vagrant.configure("2") do |config|
 config.vm.box = "dduportal/boot2docker"
 config.vm.define "dockerhost"
 config.vm.network "forwarded_port", guest: 8000, host: 8000
 config.vm.network "private_network", ip: "192.168.50.4"
 config.vm.synced_folder "../", "/project", type: "nfs"
...

My mac already have nfs because started up the service using nfsd start

In the Vagrant documentation recommend to use rsync but I didn't find a way to rsync from VM to my MAC and vice versa.

I'm using

  • Mac Yosemite
  • Vagrant 1.8.1
  • VM dduportal/boot2docker

Solution

  • I posted my question directly on the dduportal/boot2docker project.

    and this is the correct configuration if you have your custom Docker Host in different directory.

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

    Reference: https://github.com/dduportal/boot2docker-vagrant-box/issues/48