How do I share a single file, instead of sharing a whole folder like
config.vm.synced_folder "host/folder", "box/folder"
?
In other words is there a way to have something like:
config.vm.synced_folder "host/folder/file.conf", "box/folder/file.conf"
You can use the file provisioner to do this:
Vagrant.configure("2") do |config|
# ... other configuration
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
end
The accepted answer (by cdmo) didn't work for me, but was close and led me to the right solution, so cheers. To copy just one file I needed to change it to:
config.vm.synced_folder "c:/hostpath/", "/guestpath/", type: "rsync",
rsync__args: ["-r", "--include=file.text", "--exclude=*"]
Mind the arguments and their order, -r MUST be present and --include MUST precede --exclude.
If needed, instead of -r option you may use -a option which combines -r with several other options for preservation of permissions, ownership etc. (see rsync help).
My testing configuration: Vagrant 2.0.2/Win10/VirtualBox 5.2.6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With