I haven't used Vagrant on Linux for a while. When I started using the new version (Vagrant 1.8), I was faced with a problem: files created inside the guest VM didn't appear on the host machine's synced folder.
How do I force Vagrant to sync files from the guest OS to the host OS?
According to documentation, when type
option config.vm.synced_folder
parameter in Vagrantfile is not specified, Vagrant tries to choose best available option:
type
(string) - The type of synced folder. If this is not specified, Vagrant will automatically choose the best synced folder option for your environment. Otherwise, you can specify a specific type such as "nfs".
Starting with version 1.5 Vagrant introduced new "rsync synced folders" feature.
So in my case type rsync
was automatically chosen, which is one-way sync: from host to guest.
To make folders sync in two-way I added explicit definition in my Vagrantfile:
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
Of course, this will work only for VirtualBox.
Two way sync is useful for workflows, where apllication on guest machine creating files, for example, database migration files in modern web frameworks.
Note: virtualbox synced folders have known performance issues when your project has large amount of files.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments