Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Vagrant设置VM名称?_Vagrant - Fatal编程技术网

如何通过Vagrant设置VM名称?

如何通过Vagrant设置VM名称?,vagrant,Vagrant,我已经在Vagrant中设置了4个虚拟机,现在尝试在Vagrant中设置一个虚拟机的名称,因为我不想只使用ssh连接到默认的虚拟机中 我在流浪汉网站上找不到任何文档,但发现了以下内容: 但是,当我尝试时: config.vm.define“fooohost” 然后做一个漂泊者,我得到: There are errors in the configuration of this machine. Please fix the following errors and try again: vm

我已经在Vagrant中设置了4个虚拟机,现在尝试在Vagrant中设置一个虚拟机的名称,因为我不想只使用ssh连接到默认的虚拟机中

我在流浪汉网站上找不到任何文档,但发现了以下内容:

但是,当我尝试时:

config.vm.define“fooohost”

然后做一个漂泊者,我得到:

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
时,默认情况下,您将在这个VM中使用ssh。
要使用ssh连接到另一个MV,您需要指定VM名称,我怀疑您实际上编写了

config.vm.define=“fooohost”

而不是

config.vm.define“fooohost”


这将解释错误消息。(如果可以,最好显示几行实际来源。)

您链接到的答案是正确的。您是否仅添加带有
定义的行,或添加其周围的行,如链接答案中所述?如果您不显示所有代码,我们将无能为力。你熟悉吗?