具有多个同步文件夹的 Vagrant

标签 vagrant

是否可以在 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/

相关文章:

docker - 如何使用Vagrant和Kubernetes列出Docker镜像

environment-variables - 如何使用 Vagrant Docker 提供程序的 env 属性?

jenkins - 将 vagrant 上的 ssh-agent 转发给 vagrant 以外的其他用户

redis - 无法连接 docker 容器内的主机接口(interface)服务

ubuntu - Vagrant Master 和 Slave Boxes - SSH key 设置

Ubuntu + Vagrant + docker compose 不使用 Virtualbox

ruby-on-rails - 如何在 Windows PC(Windows 7/Windows 8)上部署 Rails 应用程序?

laravel - 使用宅基地从 PHPStorm 调试 laravel artisan

ssl - 将用户证书导入 windows 10 可信根证书

windows - Vagrant:将centos文件夹同步到windows