我已经在vagrant中设置了4个虚拟机,现在正尝试在vagrant中设置虚拟机的名称,因为我不希望将ssh设置为默认的虚拟机。
我在流浪者网站上找不到任何文档,但找到了:
How to change Vagrant 'default' machine name?
但是,当我尝试:
config.vm.define "foohost"
然后做一个 vagrant up 我得到:
vagrant up
There are errors in the configuration of this machine. Please fix the following errors and try again: vm: * The following settings shouldn't exist: define
因为我不希望ssh进入默认的vm。
因此,当您使用多个VM时,您可以使用下面的方法来告诉vagrant默认情况下您希望ssh哪个VM
config.vm.define "foohost", primary: true do |foohost| ... end
然后当你跑步时 vagrant ssh 在这个虚拟机中,您将默认使用ssh。 要将ssh连接到另一个mv,需要指定vm名称
vagrant ssh