访问容器中本地主机上的服务器 运行?

Accessing server, running on localhost, which is in container?

我在 docker 容器中的 localhost:3000 有一个服务器 运行,但我无法从我的 PC 访问它。

我正在尝试让这个 repo 在我的 docker

中运行
https://github.com/tamaspiros/advanced-chat

所以我的 docker conatiner/image 正在运行,然后我克隆了 repo

git clone https://github.com/tamaspiros/advanced-chat

然后我按照存储库中的说明进行一些安装

npm install && bower install

然后我启动服务器,它在 IP 上启动:127.0.0.1:3000

npm start

> chat@0.0.1 start /usr/share/nginx/html/web/git/advanced-chat
> node server.js

   info  - socket.io started
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Express server listening on  IP: 127.0.0.1 and port 3000

然后我尝试通过转到 firefox http://192.168.59.103:3000127.0.0.1:3000 不工作,因为 boot2docker)并在设置中选择 no proxy 来查看服务器。但我看不到它 我看到无法连接。

我的容器端口映射到 -p 3000:3000 我的 boot2docker ip 是 '192.168.59.103' $ boot2docker ip 192.168.59.103

我原以为我可以在这里看到服务器 192.168.59.103:3000但不确定为什么我看不到?也许是我对知识产权或其他方面缺乏了解?谁能建议?

注意 我 运行 windows7 使用 boot2docker。

EDIT1::

我根据你的建议和我最后的一些小动作得到了这个工作。

但基本上我的 Oracle VM VirtualBox Manager 中有如下内容 - boot2docker-vm - 设置 - 网络 - 端口转发规则:

我必须让 tcp-port3000 看起来像这样。但我不完全确定发生了什么。你能帮我理解这个吗?

自言自语: 我在 ubuntu container 中得到了这个工作 运行 流星,我遇到了一些其他困难。

您需要为 windows 映射 boot2ip 端口。

windows --> port@boot2ip vbox 外部 ip --> port@vm --> port@dock

如果 vm 关闭,VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port3000,tcp,,3000,,3000";

如果vm是运行,VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port3000,tcp,,3000,,3000";

(我用的是Mac,但原理是一样的)