How to share a folder created inside vagrant?
shared folders VS synced folders
Shared folders has been renamed to synced folders from v1 to v2 (docs), under the bonnet it is still using vboxsf
between host and guest (there is known performance issues if there are large numbers of files/directories).
NOTE: You need to understand it mounts host directory into the guest via
vboxsf
, NOT the other way around.
In your use case, you can
- use synced folder to map folders between host and guest (suppose they both are empty), then within the guest, copy (
rsync
is preferred) or move the project into the mapped folder. - copy the contents from guest to host (using
scp
orrsync
) folder A, and then use synced folder to map folder A on host into guest.
For example
# relative path to where Vagrantfile resides
config.vm.synced_folder "virtualenv", "/home/vagrant/devenv"
# absolute path
config.vm.synced_folder "/path/to/virtualenv", "/home/vagrant/devenv"
maps the virtualenv directory in the project directory (where the
Vagrantfile
resides) to guest/home/vagrant/devenv
.absolute path
More information that can help you understand how synced folders work =>
Vagrant shared and synced folders