Boot2Docker: Connect to container over LAN

£可爱£侵袭症+ 提交于 2019-12-03 03:48:38

You need to port forward from the OSX box to the virtual machine

VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port8080,tcp,,8080,,8080";

should do the trick

or, you could use ssh based port forwarding:

boot2docker ssh -L 8000:localhost:8000

see https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md

On your Mac, determine the IP address that it uses on your local LAN:

$ ifconfig | grep 192
    inet 192.168.1.21 netmask 0xffffff00 broadcast 192.168.1.255
    inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255

Then port forward:

$ boot2docker ssh -vnNTL 192.168.1.21:8080:localhost:8080

Now, requests that come into your Mac on port 8080 will get forwarded to the boot2docker Linux VM on port 8080. The docker server will then forward from the exposed port (VM port 8080) to the port your container is using for httpd (probably 80).

Note that "localhost" above is from the point of view of the Linux VM, not the Mac, because that is the host you are ssh'ing into.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!