运行 流浪图像的安全性

The safety of running vagrant images

我有外部 vagrant 运行ning 脚本 - 在本地 运行 类似的东西安全吗(不用冒险在生产环境中进行任何外部操作)?很久以前就在用vagrant,不过应该是在dev环境下本地使用吧?

我有以下 Vagrantfile:

config.vm.define "vmmachine" do |vmmachine|
  vmmachine.vm.hostname = "machine-dev"
  vmmachine.vm.network :private_network, ip: "192.168.10.12"
  vmmachine.vm.provision :shell, :path => "vagrant/machine/init.sh"
end

vagrant/machine/init.sh 是:

#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
# Add repo
echo "deb http://www.somewebsite.com testing main" > /etc/apt/sources.list.d/machine.list
# Add key
wget --quiet -O - https://www.somewebsite.com.key.asc | apt-key add -

apt-get update

apt-get install -q -y screen htop vim curl wget
apt-get install -q -y machine-server

service machine start

apt-get clean

还有,为什么是192.168.x.x而不是127.0.0.x?这样做有什么好处?

是的,Vagrant 绝对可以用于本地开发。我不完全确定您正在尝试 运行 什么脚本,但在我看来 运行 在本地安装它绝对是一种选择。我使用 Vagrant 作为我的本地开发服务器有一段时间了,并且知道目前有很多其他开发人员也在这样做。

Vagrant 不使用 127.0.0.x 的原因是因为您的站点 运行 位于您计算机上的虚拟机中,而不是本地计算机本身。您基本上是通过本地 IP 地址连接到 VM Vagrant 在他们的 docs:

中对 IP 地址做了一个简短的解释

While you can choose any IP you would like, you should use an IP from the reserved private address space. These IPs are guaranteed to never be publicly routable, and most routers actually block traffic from going to them from the outside world.

所以我会说他们 "officially" 建议使用 192.168.x.x 尽管他们说你可以使用几乎任何你想要的 IP。