Default shared folder in vagrant not visible

2020-07-25 10:24发布

问题:

I have a problem with synced folder in Vagrant. My config is really simple:

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.network :forwarded_port, guest: 80, host: 8080
  config.vm.synced_folder ".", "/vagrant"
end

Vagrant usually creates /vagrant folder automatically on start - this time it did not happen so I've done it manually. But when I create a file in my host system - it's not visible in guest. Any ideas why?

I've succesfully created a similar configuration with:

config.vm.box = "hashicorp/precise64"

but it's a little bit outdated and I want to use Ubuntu 16.04.

Is it a problem with my config, vagrant box, or something else?

回答1:

You could try: Make sure you have the latest version of Vagrant and VB. Restart your computer (I know, but it sometimes does help in these cases). Try again in a new directory (or vagrant destroy if you want to start fresh and don't need any old content), i.e., make sure the old .vagrant directory isn't there.

vagrant up or vagrant reload and check again.

Assuming you are using VirtualBox, make sure you don't have any "Guest Additions" issues. You could try https://github.com/dotless-de/vagrant-vbguest

If it still doesn't work, check the --debug output again as @frédéric-henri mentioned -- look for all mentions of your share name. Also "/vagrant" isn't always the default, it depends on the box. Sometimes it's "/vagrant_data" or others, but if you specify "/vagrant" in the config -- that should work.



标签: vagrant