Using DNS (FQDN) to connect between containers




I’m trying to configure our stack in docker to make full tests into Codeship. Our stack is “simple”:

  • apache webserver
  • mysql
  • redis
  • elasticsearch
  • selenium

We’re working with PHP and we would test our website using Selenium and Chrome driver. Problem is how could access to webserver from Selenium container?

In apache I have configured: and

If I test from apache container work correctly but when try to get from Selenium container I have an resolve error because container don’t know where is that domain and the container IP is not always the same IP (internal docker IPs).

If I add manually IP in /etc/hosts on the Selenium container work correctly but I don’t know how could be the best way to make it, because I’m not sure if I have to use consul, etcd or other way because I was checking consul and/or etcd but I think this will not solve my problem.

Anyone have same or similar problem and solved or have any clues please?



Have you played around with defining vhosts as discussed here: ?


Thanks for reply Ethan. Looks similar to my configuration. Problem is when try to connect from one container (Selenium) to other container (apache) because Selenium container don’t know what IP address is because don’t resolve to any IP. Easy solution could be add IP of apache container in /etc/hosts of Selenium container with the domain, something like that:


Where is the IP of apache’s container that is changing every time I start docker-compose (or run jet for tests).

I’m not sure if I explain well :S


P.S.: I’ve replaced “www” letters to “3w” because links post limitations :slight_smile:



Finally “solve” using consul + mungehost. I think is a workaround (or is not the best way to make it), but is a bit difficult this setup for browser testing from docker.



Sorry for the delay but I’m glad you got a solution. Thanks for sharing, will help out the whole community!


Can you detail exactly how you did this please?