You deployed the web service and published it with -p 8080:8000. The container is Up, docker ps shows the mapping 0.0.0.0:8080->8000/tcp, and the app logs say it's running — but every request from the host is refused:
$ curl -sS http://localhost:8080/
curl: (56) Recv failure: Connection reset by peer
The publish mapping looks right and the app is clearly up. Find out why the port is unreachable and state the fix.
web — webapp:1.4 (Flask), Up 40 minutes, 0.0.0.0:8080->8000/tcp.http://localhost:8080.$ docker ps
# web is Up, PORTS: 0.0.0.0:8080->8000/tcp (mapping present)
$ docker port web
8000/tcp -> 0.0.0.0:8080 (forward targets container:8000)
$ docker exec web ss -tlnp
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 128 0.0.0.0:5000 0.0.0.0:* users:(("python3",pid=1,fd=3))
The listener is on 0.0.0.0:5000 — but you forwarded to 8000.
You've solved it when:
docker exec web ss -tlnp (or netstat -tlnp) — while the published
forward targets container port 8000 (docker port web). The interface
is fine (0.0.0.0, not loopback); the bug is a port mismatch: Docker
forwards host:8080 → container:8000, where nothing listens. NOT
misdiagnosed as a loopback bind, a host firewall, or a malformed -p
string (the mapping is well-formed — it just points at the wrong port).
-p 8080:5000 (or make the app listen on
8000, e.g. flask run --port 8000) — and recreate the container.
docker CLI only.docker restart web does NOT help — the app still listens on 5000 after a-p 8080:8000 mapping is well-formed and binds 0.0.0.0; don't chaseEXPOSE 8000 (or a guessed -p …:8000) not make the app listendocker port web + docker exec web ss -tlnp alone?
docker restart?