Why does my Docker container's published port give an empty reply to every request?
docker run -p host:container sends traffic for the host port to a port inside the container, and Docker does not check that anything listens there. If the container port is wrong, the container stays Up and its logs stay quiet, but every request gets an empty reply. Compare the PORTS column of docker ps with the ports the image declares in docker image inspect. In this incident the host port was mapped to port 80 while nginx listened on 8080.
What it looks like
- The container is Up and never restarts.
- curl to the host port fails with an empty reply from server, not an HTTP error.
- The server's logs show no requests at all.
- The container was recreated recently from a run command typed by hand.
Commands that find the cause
docker psRunning containers. In PORTS, host:port->container_port/tcp means traffic to the host port is sent to that port inside the container; a bare port/tcp is one the image exposes that nothing publishes. The published container port must be the one the app listens on.
docker image inspect -f '{{json .Config.ExposedPorts}}' ghcr.io/nginxinc/nginx-unprivileged:1.27-alpineThe ports the image itself declares, before any run command adds to them. This is where the app inside expects traffic.
curl -sS -o /dev/null -w '%{http_code}\n' http://localhost:18081/One request the way the storefront makes it. A number is an HTTP status; 000 with a curl error means no HTTP answer came back at all, so the request never reached a server that understood it.
docker logs --tail 5 imagesWhat the server printed. A server that started cleanly and never logged a request tells you requests are not reaching it.
docker port imagesThe same mapping as PORTS, one line per published port: container port first, then the host address it is bound to.
What the evidence looked like
Recorded on a real system when this incident was captured for the game.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
851413a6528e ghcr.io/nginxinc/nginx-unprivileged:1.27-alpine "/docker-entrypoint.…" 25 seconds ago Up 25 seconds 8080/tcp, 0.0.0.0:18081->80/tcp, [::]:18081->80/tcp imagesRoot cause
The image service was recreated with host port 18081 mapped to container port 80, but nginx listens on 8080; remapping fixed it.
The fix
Recreate the container with the host port mapped to the port the app listens on:
docker rm -f images && docker run -d --name images -p 18081:8080 ghcr.io/nginxinc/nginx-unprivileged:1.27-alpineHow to prevent it
Keep the run command or a compose file in the repo instead of retyping it. Images that run as a non-root user usually listen on a high port such as 8080: check docker image inspect before mapping.
More incident guides
- Docker container exits immediately after a config change
- Docker container cannot connect to the database host
- Docker volume permission denied
- Docker container exit code 137, killed for memory
- CrashLoopBackOff after a config change
- Service returns 503 while every pod is Running
- OOMKilled and exit code 137
- Pods fail to start after a Secret change
- Requests fail after adding a NetworkPolicy
- Healthy pods restarted by a liveness probe
- Slow service with low CPU and no restarts
- Rollout stuck on ImagePullBackOff
- Pods stuck Pending with insufficient CPU
- Linux disk full: no space left on device
- systemd service keeps restarting after a deploy
- Address already in use: find what holds a port on Linux
- Linux name or service not known after a config change
- Too many open files in a systemd service