I have primarily used Ubuntu boxes in Vagrant and in those any files created within the box have been successfully synced to Windows also. Usually things like git pull
.
However, I now have centos/7
and cannot get any files to sync to Windows. If you create a file in /vagrant
it never appears anywhere in Windows - not under C:\cygwin64\
nor C:\vm\machine
. When I vagrant reload
the box, all the files created inside the box are gone, except configuration files eg. /etc/httpd/conf/httpd.conf
. Any changes in them are still present upon vagrant reload
and also vagrant halt; vagrant up
.
Here's the Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest: 80, host: 8086, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 3306, host: 3386, host_ip: "127.0.0.1"
config.vm.synced_folder "./", "/vagrant"
# I have also tried the following:
# config.vm.synced_folder "C:/vm/machine", "/vagrant"
# config.vm.synced_folder "./", "/vagrant", type: "rsync", disabled: false
end
When doing vagrant up
, both methods for synced_folder display this:
==> default: Rsyncing folder: /cygdrive/c/vm/machine/ => /vagrant
I have tried doing vagrant up
from both cmd.exe
and also from the Cygwin64 Terminal (under /c/vm/machine
). Neither of them create files to the Windows directory, which is in C:\vm\machine
.
What do I need to do to make files created in the box also sync to Windows?
When I try the same in an Ubuntu box, the file appears in Windows and does not disappear:
This is the Vagrantfile of the Ubuntu box:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "v0rtex/xenial64"
config.vm.network "forwarded_port", guest: 80, host: 8083, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 443, host: 8443, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 3306, host: 3303, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 5000, host: 5003, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 8000, host: 8003, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9090, host: 9093, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9091, host: 9193, host_ip: "127.0.0.1"
end
Upon vagrant up
for the Ubuntu box, I see this:
==> default: Mounting shared folders...
default: /vagrant => C:/vm/ubu1604-64