Docker Compose port mapping builder
Choose where a container port is published on its host. Get equivalent short and long Compose syntax, with the exposure choice in view. Free, anonymous and calculated in your browser.
Your mapping
Host 127.0.0.1, port 8080 → container port 80 (TCP).
Loopback binding requests access through the Docker host itself. It is not a guarantee of isolation; Docker version and network routing still matter.
Use either ports block under an existing service; do not paste both. These are snippets, not complete Compose files.
Host port vs container port
In "127.0.0.1:8080:80/tcp", 127.0.0.1 is the host bind address,
8080 is the published host port and 80 is the application port inside the
container. TCP is explicit. Choosing UDP changes the transport; it does not enable both protocols.
Quote the short mapping so YAML treats it as text. In long syntax, target is the numeric
container port, published is the host port as a string, and host_ip makes the bind
address explicit. IPv6 short syntax uses brackets, for example "[::1]:8080:80/tcp".
Choose the exposure deliberately
Loopback is the starting choice for host-local access. 0.0.0.0 requests all IPv4 interfaces;
:: requests all IPv6 interfaces. A specific address narrows the requested binding to that
address. IPv4 and IPv6 behavior depends on your Docker engine and network configuration.
Publishing with ports differs from expose, which does not publish a host port.
Avoid combining published ports with network_mode: host. Check your runtime’s support for host
IP binding and review the
Docker Compose ports reference
and
Docker port publishing guidance, including loopback caveats for older engines.