Vagrant 无法转发此 VM 上的指定端口 [英] Vagrant cannot forward the specified ports on this VM

查看:64
本文介绍了Vagrant 无法转发此 VM 上的指定端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 Vagrant 用于一盒配置文件.现在我想将 Vagrant 用于另一个框 (b2),但它说 bioiq 的实例正在消耗转发的端口 2222(它是).

I have Vagrant in use for one box profile. Now I want to use Vagrant for another box (b2), but it says that bioiq's instance is consuming the forwarded port 2222 (which it is).

现在,如果我使用以下配置 b2,Vagrant 仍然会尝试使用 2222.

Now, if I configure b2 with the below, Vagrant still tries to use 2222.

Vagrant.configure("2") do |config|

  config.vm.box = 'precise32'
  config.vm.box_url = 'http://files.vagrantup.com/precise32.box'

  config.vm.network :forwarded_port, guest: 22, host: 2323

  # Neither of these fix my problem 
  # config.vm.network :private_network, type: :dhcp 
  # config.vm.network :private_network, ip: "10.0.0.200"
end

我尝试了其他 SO 问题中的各种方法来设置 :forwarded_port(请参阅 此处此处).我也试过这个 Google Group post,但无济于事.我不断收到这条消息.

I've tried various ways from other SO questions to set the :forwarded_port (see here and here). I also tried this Google Group post, to no avail. I keep getting this message.

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 2222 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: 22, 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.

我不知道为什么 Vagrant 总是忽略我的指令.发布的配置不起作用.有没有人克服这个?

I don't know why Vagrant consistently ignores my directives. The posted configuration doesn't work. Has anyone overcome this?

推荐答案

ssh端口的情况下,Vagrant自己解决端口冲突:

In case of ssh port, Vagrant solves port collisions by itself:

==> ubuntu64: Fixed port collision for 22 => 2222. Now on port 2200.

但是,您仍然可以通过以下方式创建不可避免的碰撞:

However, you still can create unavoidable collision by:

  1. 创建第一个 vagrant env(它将为 ssh 获取端口 2222)
  2. 暂停那个环境(vagrant suspend)
  3. 创建第二个 vagrant env(它将再次获得端口 2222,因为它现在未使用)
  4. 尝试通过 vagrant up
  5. 再次启动第一个环境
  1. Creating first vagrant env (it will get port 2222 for ssh)
  2. Suspend that env (vagrant suspend)
  3. Create second vagrant env (it will again get port 2222, since it is now unused)
  4. Try bringing first environment up again by vagrant up

您将收到您现在收到的错误消息.

You will get the error message you are getting now.

解决方案是使用 vagrant reload,让 vagrant 丢弃虚拟机状态(这意味着它将很难关闭它 - 所以如果你有任何未保存的工作,请小心)并开始再次环境,自行解决途中的任何 ssh 端口冲突.

The solution is to use vagrant reload, to let vagrant discard virtual machine state (which means it will shut it down the hard way - so be careful if you have any unsaved work there) and start the environment again, solving any ssh port collisions on the way by itself.

这篇关于Vagrant 无法转发此 VM 上的指定端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆