用于在具有 forward_port 80、8080 的 vagrant 中配置 vm 的 Vagrantfile 抛出错误

Vagrantfile for configuring vm in vagrant having forward_port 80, 8080 is throwing error

我的 Vagrantfile 中有以下内容。

config.vm.forward_port 80, 8080

当我启动 Vagrant 时,出现此错误。我的意图是从来宾到主机的端口映射。

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

vm:
* The following settings shouldn't exist: forward_port

该块中 config 对象的成员变量应为 forwarded_port,符号类型参数为 guesthost,成员方法为 network,因此您的行应显示为:

config.vm.network 'forwarded_port', guest: 80, host: 8080