Using DNS (FQDN) to connect between containers

docker
selenium
apache
php

#1

Hi,

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:

test.domain.com and www.test.domain.com

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?

Thanks!!!


#2

Have you played around with defining vhosts as discussed here: https://medium.com/@jmarhee/running-multiple-web-applications-on-a-docker-host-with-apache-85f673f02803#.w928vc52s ?


#3

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 3wtest.domain.com because 3w.test.domain.com 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:

/etc/hosts

172.17.0.9 www.test.domain.com test.domain.com

Where 172.17.0.9 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

Thanks!

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


#4

Hi,

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.

Thanks!


#5

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


#6

Can you detail exactly how you did this please?