SSH进入特定的流浪者盒而不是默认的盒子

时间:2016-08-11 17:52:46

标签: vagrant vagrantfile

我有3个流浪盒

Activator.CreateInstance(type, null, (Dictionary<string, object>)null);
Activator.CreateInstance(type, (OperationContext)null, null);
vagrant box list

当我hashicorp/precise32 (virtualbox, 1.0.0) hashicorp/precise64 (vmware_fusion, 1.1.0) laravel/homestead (virtualbox, 0.4.2) vagrant up时,我一直登录vagrant ssh机器。

如何在此框中hashicorp/precise32

2 个答案:

答案 0 :(得分:1)

在你的项目目录中,你已经定义了一个Vagrantfile,在这个Vagrant文​​件中,你指出了需要用于你旋转的VM的框,比如

Vagrant.configure("2") do
  config.box = "hashicorp/precise32"
end

如果要从hashicorp/precise64框中创建新VM,则需要

Vagrant.configure("2") do
  config.box = "hashicorp/precise64"
end

要确保不删除任何内容,只需创建一个新文件夹和一个新的Vagrantfile。要启动新实例,请执行

vagrant up --provider vmware_fusion

答案 1 :(得分:1)

vagrant ssh {hostname}

实施例

如果您在流浪文件中声明3 Vms。

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "lb01" do |lb01|
    lb01.vm.box = "ubuntu/trusty64"
    lb01.vm.hostname = "lb01"
    lb01.vm.network :private_network, ip: "10.11.12.50"
  end

  config.vm.define "web01" do |web01|
    web01.vm.box = "ubuntu/trusty64"
    web01.vm.hostname = "web01"
    web01.vm.network :private_network, ip: "10.11.12.51"
  end

  config.vm.define "web02" do |web02|
    web02.vm.box = "ubuntu/trusty64"
    web02.vm.hostname = "web02"
    web02.vm.network :private_network, ip: "10.11.12.52"
  end
end

然后,在运行vagrant up后,我可以vagrant ssh lb01我应该登录lb01 VM。

相关问题