Vagrant 单向同步文件夹

标签 vagrant vagrantfile

我在 Vagrant 中使用同步文件夹已经有一段时间了,但行为并不符合我的预期。主机中的更改和 guest 计算机中的更改似乎都是同步的。但是,我希望仅在一个方向上同步:从主机到访客。我想创建 Vagrant 机器的部分原因是,如果我的代码不小心做了一些破坏性的事情,比如删除自身,我希望该行为被包含在一个安全的环境中。

作为引用,这是我正在使用的 Vagrantfile:

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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "hashicorp/precise32"
  config.vm.provision :shell, :path => "bootstrap.sh"
  config.vm.network :forwarded_port, host: 8080, guest: 80
  config.vm.synced_folder "test", "/test", :nfs => true
  config.vm.network "private_network", type: "dhcp"
end

其中 bootstrap.h 只执行 apt-get install nfs-common portmap .

在 Vagrant 中配置单向同步的最简单方法是什么?

最佳答案

从 Vagrant 1.5 开始,您可以使用 rsync 作为同步文件夹方法:

Vagrant.configure("2") do |config|
  config.vm.synced_folder "test", "/test", type: "rsync",
end

这是单向的。

关于Vagrant 单向同步文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23324339/

相关文章:

vagrant - `vagrant up` 在 "Waiting for domain to get an IP address..."超时

node.js - 在 Vagrant 中访问 Webpack-Server 上的 Vue 应用程序

Vagrant VMWare公共(public): Unable to set static automatically

vagrant - host_vars 和 group_vars 未加载

linux - 更改主机名 Vagrant

apache - 新 Vagrant 中的 DocumentRoot 错误

ssh - Vagrant 文件。设置 ssh 代理的区域设置

bash - 如何在 vagrant ssh bash 中配置颜色

php - Vagrant phpmyadmin php 显示为纯文本问题

mysql - 1045, "Access denied for user ' root' @'localhost'(使用密码 : NO)")