Reputation: 318
I want to have multiple VMs running on my system and for them each to have one or two folders synced with the host. I'm using vagrant coupled with virtualbox. When there is already a VM up (via vagrant up) Then a new VM is created (via vagrant up in another directory containing a different Vagrantfile) it doesn't get the shared/synced folder mounted. Is it possible to share/sync folders across multiple VMs and if so how?
Note: I have also tried using multi-machine i.e. editing the Vagrantfile to spin up multiple machines, but only one machine gets the shared folder.
From discussion below, I believe this problem may result from using Virtualbox specifically. Will update after trying to repro on another OS and using another VM application.
Upvotes: 2
Views: 2107
Reputation: 1383
As described in official documentation you can setup specific synced folders in Vagrantfile. So you can setup the same shared folder for every project by simply putting something like this into every Vagrantfile
config.vm.synced_folder "../host_shared_src_folder", "/guest_src_folder"
So I have Vagrantfile like this
Vagrant.configure(2) do |config|
config.vm.box = "base_ubuntu"
config.vm.synced_folder "../shared", "/shared"
end
And folder's layout
testvagrant
| -- shared
| -- testenv1
| -- Vagrantfile
| -- testenv2
| -- Vagrantfile
Then I just do vagrant up in both testenv1 and testenv2 folders and can see (and write to) shared folder under /shared
Upvotes: 2