无法从主机连接到docker端口

问题描述 投票:0回答:1

我无法从主机访问docker端口8080。我们有一个带有React应用程序的docker容器。我们可以从容器内部获取登录页面,但不能从主机获取。

从容器:

root@d4947f7b1710:/# wget localhost:8080
--2019-04-01 19:38:00--  http://localhost:8080/
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 492 [text/html]
Saving to: 'index.html'

index.html                                    100%[===============================================================================================>]     492  --.-KB/s    in 0s

2019-04-01 19:38:00 (49.5 MB/s) - 'index.html' saved [492/492]

来自主持人:

wget localhost:8000
--2019-04-01 19:38:59--  http://localhost:8000/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8000... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.Retrying.

也尝试了wget 0.0.0.0:8000但得到了相同的结果。端口似乎正确映射:

docker port d4947f7b1710
8080/tcp -> 0.0.0.0:8000

用于启动容器的命令:

docker run -d -p 8000:8080 <docker repo><version>

docker dockerfile
1个回答
2
投票

可能是你从我在帖子的最后部分看到的端口反转了端口

© www.soinside.com 2019 - 2024. All rights reserved.