码头机的端口转发? [英] Port forwarding in docker-machine?

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

问题描述

由于 boot2docker 已被弃用,我已切换到 docker-machine ,但我不知道如何打开来自 docker-machine 的端口。在 boot2docker 我可以这样做:

Since boot2docker is deprecated I've switched to docker-machine but I don't know how to open a port from docker-machine. In boot2docker I could do like this:

boot2docker ssh -L 27017:localhost:27017

只要连接SSH连接,这将将端口27017从VirtualBox转发到本地主机27017打开。请注意,我不是想在VirtualBox中永久打开端口的方法。如何使用 docker-machine 实现这一点?

This would forward port 27017 from VirtualBox to localhost 27017 as long as the SSH connection is open. Note that I'm not looking for a way to open the port permanently in VirtualBox. How can I achieve this with docker-machine?

推荐答案

您仍然可以从Docker机使用的VirtualBox访问VBoxmanage.exe命令:

You can still access the VBoxmanage.exe command from the VirtualBox used by docker machine:

VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port27017,tcp,,27017,,27017";




  • 使用 docker-machine info 获取您的vm的名称。

  • 如果vm尚未启动,则使用 modifyvm 。 >

    • Use docker-machine info to get the name of your vm.
    • use modifyvm if the vm isn't started yet.
    • 请参阅此答案

      这是目前的解决方法,等待将参数传递给 docker-machine的可能性ssh :请参阅问题691

      That is the current workaround, pending the possibility to pass argument to docker-machine ssh: see issue 691.

      另一种解决方法是转发端口,并直接使用虚拟机的IP:

      The other workaround is to not forward port, and use directly the IP of the VM:

       $(docker-machine ip default)
      

      这篇关于码头机的端口转发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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