在Docker容器之外看不到Dockerized Aurelia应用程序-不侦听0.0.0.0 [英] Dockerized Aurelia App Is Not Visible Outside of Docker Container - Not listening on 0.0.0.0

查看:160
本文介绍了在Docker容器之外看不到Dockerized Aurelia应用程序-不侦听0.0.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在标准节点docker容器中运行一个Aurelia应用,它正在侦听端口8080.并以预期的HTML响应.但是我无法通过主机(容器外部)上的映射端口访问应用程序.

I'm running an Aurelia app inside of the standard node docker container and it is listening on port 8080. Within the container, I have tested that it's running using curl; and it responds with the expected HTML. But I cannot reach the app via the mapped port on the host (outside the container).

我正在运行以下命令来启动容器

I'm running the following command to start the container

$ docker run -it --rm -p 8080:8080 -v ${PWD}:/app node bash

然后在容器中,安装cli并创建一个新应用

Then inside the container, I install the cli and create a new app

# npm install -g aurelia-cli
# au new

创建默认应用后,我cd进入应用目录并运行该应用.

After creating a default app, I cd into the app directory and run the app.

# au run

如上所述,我可以使用curl http://localhost:8080验证应用程序是否正在运行.但是,在主机上,我无法访问该应用程序:

As I said above, I can verify the app is running using curl http://localhost:8080. However, on the host, I cannot access the app:

$ curl http://localhost:8888
curl: (52) Empty reply from server

最初,我认为这是一个docker问题.请参阅此问题.但是事实证明,Aurelia正在监听localhost而不是0.0.0.0.

Originally, I thought this was a docker problem. See this question. But it turns out that Aurelia is listening on localhost rather than 0.0.0.0.

推荐答案

运行具有host选项集的Aurelia允许服务器侦听0.0.0.0,因此它将在docker容器中正确映射.

Running Aurelia with the host option set allows the server to listen on 0.0.0.0, so it will map properly in a docker container.

au run --host 0.0.0.0 

这篇关于在Docker容器之外看不到Dockerized Aurelia应用程序-不侦听0.0.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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