Vagrant支持多个同步文件夹

36

在Vagrantfile中是否可以设置多个同步文件夹?这是我的当前配置(使用vaprobash):

# Use NFS for the shared folder
config.vm.synced_folder ".", "/vagrant/Sites",
          id: "core",
          :nfs => true,
          :mount_options => ['nolock,vers=3,udp,noatime']

# Use NFS for the shared folder
config.vm.synced_folder "../Code", "/vagrant/Code",
          id: "core",
          :nfs => true,
          :mount_options => ['nolock,vers=3,udp,noatime']

只有第二个映射被加载,另一个被忽略 - 所以我最终得到了一个正确映射的/vagrant/Code目录,但没有vagrant/Sites

1个回答

63

2021更新:

在2021年,无需唯一标识符或成为nfs,只需列出您同步的文件夹即可:

config.vm.synced_folder ".", "/vagrant/Sites"
config.vm.synced_folder "../Code", "/vagrant/Code"
我只需要为每个挂载点设置唯一的ID,然后重新加载vagrant box。
# Use NFS for the shared folder
config.vm.synced_folder ".", "/vagrant/Sites",
      id: "sites", # <--- this ID must be unique
      :nfs => true,
      :mount_options => ['nolock,vers=3,udp,noatime']

# Use NFS for the shared folder
config.vm.synced_folder "../Code", "/vagrant/Code",
      id: "code", # <--- different from this one
      :nfs => true,
      :mount_options => ['nolock,vers=3,udp,noatime']

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接