【发布时间】:2017-04-05 09:12:32
【问题描述】:
我在 microsoft azure 云中的 ubuntu linux 系统上运行两个容器(一个名为 eva 的 node.js 应用和该应用使用的 postgres-db):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
339b252e9895 eva "node app.js" 17 hours ago Up 17 hours 0.0.0.0:8086->8086/tcp eva
91a39d88c1eb postgres "/usr/lib/postgresql/" 19 hours ago Up 19 hours 5432/tcp postgres
我在 8086 端口上暴露了 node.js 应用,并使用以下命令从镜像启动容器:
sudo docker run --name eva -p 8086:8086 eva
我已在 azure 控制台上打开此 linux 服务器的端口并尝试访问它,但 chrome 显示连接被拒绝错误。 我也尝试通过 curl 在本地访问它:
sudo curl --trace curl.out localhost:8086
这是 curl.out:
== Info: Rebuilt URL to: localhost:8086/
== Info: Trying 127.0.0.1...
== Info: Connected to localhost (127.0.0.1) port 8086 (#0)
=> Send header, 78 bytes (0x4e) 0000: 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a GET / HTTP/1.1.. 0010: 48 6f 73 74 3a 20 6c 6f 63 61 6c 68 6f 73 74 3a Host: localhost: 0020: 38 30 38 36 0d 0a 55 73 65 72 2d 41 67 65 6e 74 8086..User-Agent 0030: 3a 20 63 75 72 6c 2f 37 2e 34 37 2e 30 0d 0a 41 : curl/7.47.0..A 0040: 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a 0d 0a ccept: */*....
== Info: Recv failure: Connection reset by peer
== Info: Closing connection 0
我已经在我的 MacOS 上本地完成了相同的操作,并且它正在工作。此外,我通过 scp 将源文件移动到 linux 系统自己部署了该应用程序,并仅使用 node 命令在端口 8085 上自己运行该应用程序;它也有效。
为什么我无法在 ubuntu 的 docker 容器中访问我的 node.js 应用程序?
【问题讨论】:
-
从MacOS复制到Linux,在linux下能用吗?
-
容器本身呢?是否有任何进程在监听 8086? (检查例如
docker exec -it eva ss -tnlp)
标签: node.js azure ubuntu docker