LastTribunal
LastTribunal

Reputation: 1

Docker containers work on port 80 only

I tried this on multiple machines (Win10 and server 2016), same result using this tutorial: https://docs.docker.com/docker-for-windows/#set-up-tab-completion-in-powershell

This works

docker run -d -p 80:80 --name webserver nginx

Any other port, fails with

docker run -d -p 8099:8099 --name webserver nginx --> ERR_EMPTY_RESPONSE

Looks like Docker/nginx is listening failing on this port, but failing. Telneting to this port shows that the request goes through, but disconnects right away. This is different from when a port is not being listened to on at all.

Upvotes: 0

Views: 1593

Answers (1)

BMitch
BMitch

Reputation: 263866

There are two ports in that list. The first port is the one docker publishes on the host for you to connect to remotely. The second port is where to send that traffic in the container. Docker doesn't modify the application, so the application itself needs to be listening on that second port. By default, nginx listens on port 80. Therefore, you could run:

docker run -d -p 8099:80 --name webserver nginx

To publish on port 8099 and send that traffic to an app inside the container listening on port 80.

Upvotes: 3

Related Questions