Desk Clarity

A field guide to everyday digital problems.

Developer tools / Practical guide

Docker EXPOSE Does Not Publish a Host Port: Inspect the Mapping and Listener

EXPOSE documents an intended container port.

By ON Lab2 min readSources checked November 10, 2026 (KST)

EXPOSE documents an intended container port. A host client needs an appropriate published mapping, and the application still has to listen on the correct interface and port inside the container.

Inspect the boundary before changing the service

The commands below use placeholder names. They illustrate a diagnostic workflow and were not run against a live container in this review. Match the Docker context and project before inspecting your own service.

# Read current state without changing the container.
docker port demo
docker inspect demo --format '{{json .NetworkSettings.Ports}}'
# Example mapping for a future reviewed configuration:
# ports:
#   - "127.0.0.1:8080:80"

What to compare

Read the mapping from the host side to the container side: in the example, a host client uses port 8080 and the container service uses port 80. A published mapping does not prove that the process is healthy. An application bound only to 127.0.0.1 inside a bridge-network container may not accept traffic forwarded to its container interface. Conversely, a service listening correctly inside the container is not necessarily published to the host.

Choose the next action

Inspect the application startup log for its actual bind address and port. Compare that port with the container side of the mapping, then test from the intended client location. For a service intended only for this host, specify a loopback host address rather than silently publishing on all interfaces. Verify IPv4 and IPv6 requirements separately. If the consumer is another service on the same Compose network, use that service endpoint instead of introducing a host port without a need.

Limits and verification

Changing published ports usually requires recreating the container through its owner configuration. Do not run an unrelated second copy just to test a mapping. Docker documents a localhost publishing caveat for Engine releases before 28.0.0; do not treat loopback publication on an older engine as a complete exposure guarantee. Runtime connectivity was not tested here.

Related: A Container Cannot Reach Host Localhost: Choose the Correct Network Endpoint.

Official Docker documentation checked November 10, 2026 (KST). Docker Compose 2.35.1 configuration parsing was available, but the Docker daemon was not running. These pages do not claim a live container connectivity, storage, health or recovery test.

Sources & further reading