Selenium Grid with Docker containers on different hosts

白昼怎懂夜的黑 提交于 2019-12-07 16:23:14

问题


I like to setup a Selenium Grid on AWS with the official Docker images, that can be found here https://github.com/SeleniumHQ/docker-selenium

Hub and nodes should reside on different machines / docker hosts.

I use an ambassador container, as described here: https://docs.docker.com/articles/ambassador_pattern_linking/

(hub) --> (selenium-ambassador) --network--> (selenium-ambassador) --> (node)

I created two EC2 instances and executed the following commands:

On the hub machine:

$ docker run -d --name selenium-hub selenium/hub:2.47.1
$ docker run -d --link selenium-hub:selenium-hub --name selenium_ambassador -p 4444:4444 svendowideit/ambassador

On the node machine:

$ docker run -d --name selenium_ambassador --expose 4444 -e SELENIUM_PORT_4444_TCP=tcp://<public-AWS-EC2-IP>:4444 svendowideit/ambassador
$ docker run -d --link selenium_ambassador:selenium-hub selenium/node-chrome:2.47.1

After running the last command, I get the following error message on the node machine:

Not linked with a running Hub container

Security groups on each EC2 machine allow port 22 and 4444.

I hope, anyone can help me or give me a clue? Thanks in advance.


回答1:


After some more research, I've found out that no extra ambassador container is necessary. The node and hub can communicate directly after setting the appropriate parameters / environment variables REMOTE_HOST, HUB_PORT_4444_TCP_ADDR, HUB_PORT_4444_TCP_PORT. There is also a respective resolved issue https://github.com/SeleniumHQ/docker-selenium/issues/51

To put it in a nutshell, just execute the following commands:

Hub

$ docker run -d -p 4444:4444 --name selenium-hub selenium/hub:2.47.1

Node

$ docker run -d -p 5555:5555 -e REMOTE_HOST="http://<PASTE-NODE-IP>:5555" -e HUB_PORT_4444_TCP_ADDR="<PASTE-HUB-IP>" -e HUB_PORT_4444_TCP_PORT="4444" --name chrome-node selenium/node-chrome:2.47.1


来源:https://stackoverflow.com/questions/32074836/selenium-grid-with-docker-containers-on-different-hosts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!