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 listening — 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. Find out why the port is unreachable and state the fix.
web — myapp:2.3 (gunicorn), Up 2 hours, 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 configured)
$ docker exec web ss -tlnp
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 2048 127.0.0.1:8000 0.0.0.0:* users:(("gunicorn",pid=1,fd=5))
The listener is on 127.0.0.1, not 0.0.0.0.
You've solved it when:
127.0.0.1:8000)0.0.0.0:8000) — via `docker exec web ss
-tlnp (or netstat -tlnp`). A published port forwards to the container's
eth0, so a loopback-only listener can never be reached from the host. NOT
misdiagnosed as a wrong -p mapping, a host firewall, or a Docker
networking bug (the mapping is correct — docker port web confirms it).
0.0.0.0 (e.g. gunicorn--bind 0.0.0.0:8000, Flask --host=0.0.0.0) and recreate the container.
docker CLI only.docker restart web does NOT help — the app still binds 127.0.0.1 on-p 8080:8000 mapping is correct; don't chase the publish flag or a0.0.0.0:8000 but not 127.0.0.1:8000127.0.0.1 a common framework default (gunicorn, Flask dev127.0.0.1:8000 from inside the