Docker Community Forums

Share and learn in the Docker community.

Multiple Containers :: Best Practice Ports

(Famoustm) #1

Expected behavior

Mapping port any(3000):80 results in:

Actual behavior


Desired behavior


Shouldn’t have to add the port at the end

And obviously it would be nice to add many websites like in a httpd.conf, however is that the recommended way – opening multiple ports? Doesn’t that make the site more hackable?

Thank you for your help.

(Kylesoskin) #2

I’m not sure I know what you mean? If you want Apache in a container to propagate through to port 80, you have a couple option. You can bind the docker internal port 80, to the host port 80. Meaning do something like ‘docker run -p 80:80 somewebapp’. Then you can go to http://$host_ip and it will go to the web app in the container. Of you want it to be on port 3000, but accessable via port 80 in a web browser you will need to nat it through or have another interface on the host.

So you could run you container and have it listen on port 3000, and then on the host where the docker daemon is running, bring up a network interface with the ip of the website, and port 80, and nat it to port 3000

(Famoustm) #3

Thanks for the info, but maybe I should just ask the question rather than
trying to understand the solution myself. Question:
I would like to run multiple docker containers as websites with normal
domain names. How do I do that with best practice?

Thank you

(Wolfgangpfnuer) #4

forward port 80 to nginx service. configure that to forward traffic for a domain to http://service_name.