首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用相同端口转发规则的多个VM的Portforwarding

使用相同端口转发规则的多个VM的Portforwarding
EN

Stack Overflow用户
提问于 2013-12-11 21:23:51
回答 1查看 3K关注 0票数 1

我目前有一个vagrant环境,每个VM都有一个端口转发规则从主机设置到客户。但是,这个转发规则的问题是,我不能让多个VM同时通过游走器运行,同时具有类似的端口转发规则。

似乎我需要某种端口代理来处理这个问题。有什么东西已经被烤成了迷途/虚拟盒,可以支持这一点吗?

代码语言:javascript
复制
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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-11 21:27:30

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

代码语言:javascript
复制
Vagrant.configure("2") do |config|
  config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
end

有关更多细节,请参见documentation

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20530203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档