Google 应用引擎:docker 自定义运行时容器的 IP,node.js

Google app engine: IP of docker custom runtime container, node.js

这与这里的 Whosebug 问题有关:Run Websocket on GAE .

我正在尝试 运行 在沙盒 google 自定义 运行time nodejs 环境中使用 boot2docker 参数的 mozilla's browserquest 版本如下:

docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): darwin/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.4.1
Git commit (server): a8a31ef

我已经控制了很多潜在的错误,包括将服务器转移到端口 8001 并公开该端口以避免与为 google 应用引擎管理员保留的 8000 端口发生冲突。

但是我目前陷入困境,因为据我所知,要成功完成此任务,我需要向我的应用程序提供服务器的 ip 才能使用 websockets(有关此问题的说明,请参阅https://github.com/jdeskins/socketio-gcmvm and the comment in the readme.md therein about using http://[DOCKER-IP]:3000 rather than http://localhost:3000,说查一下)。

我特别想知道是否有任何优雅或简单的技术来配置 dockerfile,或更改一些其他配置设置,或确定 ip,以便可以自动指向使用 websockets 的应用程序(例如 browserquest ) 当客户端尝试连接到服务器上的 websocket 时到正确的 ip。

最终我想要的是我可以添加到我的项目中的东西,这样当我输入时

gcloud preview app run .

然后将我的浏览器指向 http://localhost:8080,我将能够进入游戏(运行ning npm 从我的主项目目录开始,然后打开 Web 应用程序的入口点(/client 文件夹中的index.html)有效)。

摘自 OP 的评论:

我找到了解决这个问题的方法 - 如果手动输入 ip(对于本地开发,运行 boot2docker ip 给出所需的 ip,对于生产,ping http:// .appspot.com 给出了该实例所需的 ip。所以这个问题可以解决,但是找到一种方法从其中读取 docker 容器的 ip 可能是有用的,以便可以自动执行配置 IP 地址的过程,以便在发出服务器请求时将应用程序指向