Careeroza
Publishing Ports
Port Mapping
A container has its own network stack. To reach it from your machine, publish a port with -p HOST:CONTAINER.
| Option | Effect |
|---|---|
-p 8080:80 | host port 8080 → container port 80 on all interfaces |
-p 127.0.0.1:8080:80 | only reachable from this machine |
-p 80 | a random free host port (see docker port) |
Note: Inside the container, the app must listen on 0.0.0.0, not 127.0.0.1, or published ports will not reach it.
Check the Mapping
Example
docker port webExample output
80/tcp -> 0.0.0.0:8080