无法在流浪汉中同步文件夹

时间:2017-06-26 06:47:31

标签: vagrant vagrantfile

我正在使用流浪盒&ubuntu / trusty64'。我试图在流浪汉中同步文件夹,为此,我修改了我的流浪文件。该文件是:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "foo-box"
  config.vm.network "forwarded_port", guest: 8000, host: 8000, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"

  # Work around disconnected virtual network cable.
  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
  end
Vagrant.configure("2") do |config|
  config.vm.synced_folder "C:/fullstack/vagrant", "home/vagrant"
end

  config.vm.provision "shell", inline: <<-SHELL
    apt-get -qqy update
    apt-get -qqy upgrade
    apt-get -qqy install make zip unzip postgresql

    apt-get -qqy install python3 python3-pip
    pip3 install --upgrade pip
    pip3 install flask packaging oauth2client redis passlib flask-httpauth
    pip3 install sqlalchemy flask-sqlalchemy psycopg2 bleach

    apt-get -qqy install python python-pip
    pip2 install --upgrade pip
    pip2 install flask packaging oauth2client redis passlib flask-httpauth
    pip2 install sqlalchemy flask-sqlalchemy psycopg2 bleach

    su postgres -c 'createuser -dRS vagrant'
    su vagrant -c 'createdb'
    su vagrant -c 'createdb news'
    su vagrant -c 'createdb forum'
    su vagrant -c 'psql forum -f /vagrant/forum/forum.sql'

    vagrantTip="[35m[1mThe shared directory is located at /vagrant\\nTo access your shared files: cd /vagrant[m"
    echo -e $vagrantTip > /etc/motd

    wget http://download.redis.io/redis-stable.tar.gz
    tar xvzf redis-stable.tar.gz
    cd redis-stable
    make
    make install

    echo "Done installing your virtual machine!"
  SHELL
end

我也试过https://stackoverflow.com/questions/29731003/synced-folder-in-vagrant-is-not-syncing-in-realtime给出的答案,但没有帮助。

我在主机上的项目路径是C:\fullstack。文件夹fullstack的内容是

README.md  vagrant/  Vagrantfile

此外,vagrant文​​件夹的内容是

catalog/  forum/  tournament/  Vagrantfile

vagrantfile文件中的内容相同。 我试图在流浪者目录中的来宾机器中创建一个空目录,但该目录没有在主机中显示。请提出建议。

1 个答案:

答案 0 :(得分:1)

您不需要重新引入配置部分,只需将您的Vagrantfile设为

即可
Vagrant.configure("2") do |config|
  config.vm.box = "foo-box"
  config.vm.network "forwarded_port", guest: 8000, host: 8000, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"

  # Work around disconnected virtual network cable.
  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
  end

  config.vm.synced_folder "C:/fullstack/vagrant", "home/vagrant/stack"

同样在/home/vagrant文件夹上直接同步并不是很好,因为这个文件夹有.ssh文件夹(ssh可能不起作用)和bash信息,最好有一个主要家的子目录文件夹中。