【问题标题】:Portforwarding for multiple VMs using same port forwarding rules使用相同端口转发规则的多个虚拟机的端口转发
【发布时间】:2013-12-11 21:23:51
【问题描述】:

我目前有一个vagrant 环境,其中每个虚拟机都有一个从主机到来宾的端口转发规则设置。但是,此转发规则的问题在于,我不能同时通过 vagrant 运行多个具有类似端口转发规则的虚拟机。

看来我需要某种端口代理来处理这个问题。是否有一些已经融入 vagrant/virtualbox 的东西可以支持这一点?

Traceback from Vagrant when I try running another VM with the same forwarding rules:
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 8000 is already in use
on the host machine.

To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:

 config.vm.network :forwarded_port, guest: 8000, host: 1234

Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding.

【问题讨论】:

    标签: virtualbox vagrant


    【解决方案1】:

    您可以使用:auto_correct 参数来定义端口,然后 Vagrant 将寻找另一个(未使用的)端口:

    Vagrant.configure("2") do |config|
      config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
    end
    

    有关详细信息,请参阅documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 1970-01-01
      • 2020-01-22
      • 1970-01-01
      • 1970-01-01
      • 2015-07-08
      相关资源
      最近更新 更多