I have the need of running multiple docker containers as micro services. That problem I am facing is that when trying to use host headers is that I cannot access the containers.
I launch the nginx image:
docker run -d -p 80:80 --name webserver nginx
I can access the website using a browser by typing: http://docker
If I ping docker I get 10.0.75.2
I can also access the website using a browser by typing: http://10.0.75.2
I now add:
- www.client1.localhost 10.0.75.2
- www.client2.localhost 10.0.75.2
into the host file.
If I ping both www.client1.localhost and www.client2.localhost I get a response from 10.0.75.2
However if I now try to browse to either www.client1.localhost or www.client2.localhost I get this response:Not Found
HTTP Error 404. The requested resource is not found.
Looking at the headers I see:
Content-Type text/html; charset=us-ascii
Date Thu, 02 Jun 2016 22:30:30 GMT
So I stopped IIS to see if that made any difference but I get exactly the same response.
So the question is how can I use host headers (that is not docker) to access a docker container? What is mapping the host header docker to 10.0.75.2 since it is not in the host file?
Is the only option to use different port numbers?
If I can get this working I would use a docker container running haproxy to forward the request to the appropriate container. This is to mimic our production environment.