简体   繁体   中英

Not able to connect to docker port from host machine

I'm not able to access docker port 8080 from the host machine. We have a docker container with a React application. We are able to get the landing page from inside the container but not from the host.

From the container:

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]

From the host:

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.

Also tried wget 0.0.0.0:8000 but got the same result. The ports seem to be mapped correctly:

docker port d4947f7b1710
8080/tcp -> 0.0.0.0:8000

Command used to start the container:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM