我创建了一个包含以下内容的 Vagrantfile:
Vagrant::Config.run do |config|
config.vm.define :foo do |cfg|
cfg.vm.box = 'foo'
cfg.vm.host_name = "foo.localdomain.local"
cfg.vm.network :hostonly, "192.168.123.10"
end
Vagrant.configure("2") do |cfg|
cfg.vm.customize [ "modifyvm", :id , "--name", "foo" , "--memory", "2048", "--cpus", "1"]
cfg.vm.synced_folder "/tmp/", "/tmp/src/"
end
end
之后vagrant up
或者vagrant reload
我得到:
[foo] Attempting graceful shutdown of VM...
[foo] Setting the name of the VM...
[foo] Clearing any previously set forwarded ports...
[foo] Fixed port collision for 22 => 2222. Now on port 2200.
[foo] Creating shared folders metadata...
[foo] Clearing any previously set network interfaces...
[foo] Preparing network interfaces based on configuration...
[foo] Forwarding ports...
[foo] -- 22 => 2200 (adapter 1)
[foo] Booting VM...
[foo] Waiting for VM to boot. This can take a few minutes.
[foo] VM booted and ready for use!
[foo] Setting hostname...
[foo] Configuring and enabling network interfaces...
[foo] Mounting shared folders...
[foo] -- /vagrant
我的问题是:
- 为什么 Vagrant 挂载
/vagrant
共享文件夹?我读过共享文件夹已被弃用,有利于同步文件夹,而且我从未在我的 Vagrantfile 中定义任何共享文件夹。 - 为什么没有设置同步文件夹?
我在 MacOX 10.8.4 上使用 Vagrant 1.2.7 版。