Search code examples
dockervagrantvagrantfile

Can't access vagrant folder on vagrant machine (Stale file handle)


I'm currently stuck on a problem for 2 days already. I've recently updated my mac OS to OS Catalina (I know I should have waited) and I cant access the /vagrant folder on the vagrant machine.

My nfs configuration looks like this:

project_config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp', 'fsc', 'nolock', 'actimeo=2']

And this is the output when I try to execute an ls in vagrant ssh:

vagrant@project:/vagrant$ ls
ls: cannot open directory '.': Stale file handle

There is also running a Docker container inside my vagrant and the installation looks like this (Vagrantfile):

project_config.vm.provision "docker" do |d|
  d.build_image "/vagrant/docker/reverse-proxy", args: "-t='reverse-proxy'"
  d.run "reverse-proxy", args: "-v '/var/run/docker.sock:/var/run/docker.sock' -p 80:80 -p 443:443 -p 8080:8080"
end

Error I get after executing a vagrant up:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

docker build -t='reverse-proxy' /vagrant/docker/reverse-proxy

Stdout from the command:



Stderr from the command:

unable to prepare context: path "/vagrant/docker/reverse-proxy" not found

I think that this error is related to the vagrant folder. Like access or something like that.

Thanks


Solution

  • Fix:

    I finally managed to fix it!

    The problem was that my project was located in the Documents folder of my Mac /Users/USERNAME/Documents/project but this doesn't work anymore so I have moved the project to a new folder called Projects in my home directory. /Users/USERNAME/Projects/project.

    I hope I can help someone with this.