Vagrant 流浪配置错误-“;必须指定一个方框;

Vagrant 流浪配置错误-“;必须指定一个方框;,vagrant,vagrantfile,Vagrant,Vagrantfile,我的配置如下所示,这些盒子工作正常: 但是一旦我关掉电脑,我就不能再回去了。 运行vagrant up,我得到以下错误: Bringing machine 'node1' up with 'virtualbox' provider... Bringing machine 'node2' up with 'virtualbox' provider... Bringing machine 'node3' up with 'virtualbox' provider... Bringing mach

我的配置如下所示,这些盒子工作正常:



但是一旦我关掉电脑,我就不能再回去了。 运行
vagrant up
,我得到以下错误:

Bringing machine 'node1' up with 'virtualbox' provider...
Bringing machine 'node2' up with 'virtualbox' provider...
Bringing machine 'node3' up with 'virtualbox' provider...
Bringing machine 'node4' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* A box must be specified.

怎么了?提前感谢。

哼哼您的Vagrant文件写得不是很好,您创建了一个循环,用一个节点变量创建了4个实例,但仍然使用config.vm

如果您想保持简单,请改为

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

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|

  (1..4).each do |i|

    config.vm.define "node#{i}", autostart:true do |node|

        node.vm.box = "ubuntu/trusty64"
        node.vm.hostname="node#{i}"
        node.vm.network "private_network", ip: "192.168.59.#{i}"
        node.vm.synced_folder "~/Documents/csunp/unp", "/vagrant/unp"
        node.vm.provider "virtualbox" do |v|
            v.name = "node#{i}"
            v.memory = 512
            v.cpus = 1
        end
    end
  end
end
如果对所有4个虚拟机使用相同的框,则可以编写为

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

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/trusty64"
  config.vm.synced_folder "~/Documents/csunp/unp", "/vagrant/unp"

  (1..4).each do |i|

    config.vm.define "node#{i}", autostart:true do |node|

        node.vm.hostname="node#{i}"
        node.vm.network "private_network", ip: "192.168.59.#{i}"
        node.vm.provider "virtualbox" do |v|
            v.name = "node#{i}"
            v.memory = 512
            v.cpus = 1
        end
    end
  end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/trusty64"
  config.vm.synced_folder "~/Documents/csunp/unp", "/vagrant/unp"

  (1..4).each do |i|

    config.vm.define "node#{i}", autostart:true do |node|

        node.vm.hostname="node#{i}"
        node.vm.network "private_network", ip: "192.168.59.#{i}"
        node.vm.provider "virtualbox" do |v|
            v.name = "node#{i}"
            v.memory = 512
            v.cpus = 1
        end
    end
  end
end