是否可以在 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
最佳答案
2021 年更新:
2021 年,无需唯一 ID 或 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']
关于具有多个同步文件夹的 Vagrant ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31667516/