Exposing ports in Docker won't work
From your output: 0.0.0.0:32777->8080/tcp
. That says port 32777 listening on all interfaces will be mapped (with NAT and docker-proxy) to port 8080 inside the container. Therefore you'd need to access port 32777 instead of 8080. This random port mapping happens when you expose a port and share it with -P
.
If you want to share a specific port without a random mapping, you can define it with the lower case p option: -p 8080:8080
or even -p 8888:8080
to map port 8888 into port 8080 of the container.
From the chat session, this turned out to be the application listening on loopback inside the container. With netstat -lnt
, it showed:
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN
Updating the application to bind to 0.0.0.0 allowed the port forwarding to work as expected.