gpt4 book ai didi

docker - 无法从主机连接到docker端口

转载 作者:行者123 更新时间:2023-12-02 21:09:40 26 4
gpt4 key购买 nike

我无法从主机访问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 运行-d -p 8000:8080 <docker repo>: <version>

最佳答案

可能是您将端口与我在帖子的最后一部分中看到的相反了

关于docker - 无法从主机连接到docker端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55462446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com