简体   繁体   中英

no route to host between 2 docker containers in same host

I have two docker containers which runs on the same host(centos 6 server).

container 1 >> my web application (Ports mapped to some random port of host)
container 2 >> python selenium testscripts ( Runs headless Firefox)

My Test cases fails saying problem loading page
Basically the issue is that the second container or any other container residing on the same host is not able to access my Web application. But my web app is accesible to outside world

I linked both containers and still i am facing the problem
I tried replicating the same setup in my laptop(ubuntu) and its working fine!!!

Any help appreciated !! Thanks in advance

I think order matters in linking containers. You should start container1 the web application and then link container2 with webapp .

You need to change your selenium scripts to use the docker link id or alias as the hostname.

For example if you did:

$ sudo docker run -d --name webapp my/webapp
$ sudo docker run -d -P --name selenium --link webapp:webapp my/selenium

then your selenium scripts should point to http://webapp/

I had this problem in Fedora(22) - for some containers (not all). Upon inspection, it showed up there is an special DOCKER chain on the iptables, that can make some connections go loose. Appending an accept rule for that chain made things work:

sudo iptables -A DOCKER -p tcp -j ACCEPT  

(While searching for the problem before hitting this question, there are suggestions this also occurs in CentOS and RHEL)

Yes the order of container launch does matter, But i am launching my web application container through jenkins.

jenkins is configured in container 2. So i can not launch my web application(container 1) manually.

Is there anyother solution for this, something like bidirectional linkage??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM