✦ For everyone, free.

Practical knowledge for real and everyday life

Home

7.3.1.1 Missing Port Publishing

A focused guide to Missing Port Publishing, connecting core concepts with practical Docker and container operations.

Missing port publishing is one of the most common causes of "container running, but unreachable" confusion — a container is started without the -p flag, leaving its application correctly running and listening internally, but with no path from the host into that internal port.

Recognizing This Specific Cause

A container running without any port publishing has no externally reachable port at all, regardless of how correctly its internal application is configured and listening.

docker run -d myapp:1.0
curl http://localhost:8080

This fails to connect, not because anything is wrong with the application, but simply because no port was ever published for this container.

Confirming Publishing Is Actually Missing

Checking a container's current port mappings directly confirms whether publishing was configured at all.

docker port myapp

An empty result here confirms no ports are currently published for this container.

The Fix: Adding Explicit Port Publishing

Recreating the container with an explicit -p flag resolves this specific issue directly.

docker run -d -p 8080:8080 myapp:1.0
curl http://localhost:8080
Why This Is Such a Common Mistake

Because a container without published ports still starts successfully and appears to be running normally in docker ps, this particular misconfiguration produces no obvious error signal — the only symptom is the specific, separate observation that the application isn't reachable from outside, which can initially seem confusing if publishing isn't the first thing checked.

docker ps

This shows the container running normally, giving no direct indication that port publishing was omitted.

Why Recognizing Missing Port Publishing Matters

Checking for this specific, common, and easily overlooked cause early in troubleshooting an unreachable container saves significant time compared to investigating less likely explanations first, since this single oversight accounts for a substantial share of "container won't respond" confusion.