如何通过docker-compose而不是使用docker启动Selenium Hub和一个链接的节点? [英] How to start selenium hub and one linked node via docker-compose instead of using docker?
问题描述
我可以通过以下方式启动硒集线器映像:
I can start a selenium hub image via:
docker run --rm=true -P -p 4444:4444 --name selenium-hub selenium/hub
并通过以下方式添加一个firefox worker:
and add a firefox worker via:
docker run --rm=true --link selenium-hub:hub selenium/node-firefox
继续 http:// localhost:4444 / grid / console 然后将显示网格很好。
Going on http://localhost:4444/grid/console then will show the grid just fine.
我不想每次都使用docker,但是通过<$ c进行了相同的设置$ c> docker-compose 。
I don't want to use docker each time but have the same setup via docker-compose
.
因此,我想我可以在 docker-compose中做到这一点。 yml
:
selenium_hub:
image: selenium/hub
ports: ["4444:4444"]
links:
- selenium_firefox_worker
selenium_firefox_worker:
image: selenium/node-firefox
在运行 docker-compose up
之后,我得到了m消息:
Yet after running docker-compose up
I get the message:
selenium_firefox_node_1 | Not linked with a running Hub container
selenium_firefox_node_1 exited with code 1
,因此网格不会
我认为我可能以错误的顺序进行了链接,甚至:
I thought that I may be doing the linking in the wrong order, yet even:
selenium_hub:
image: selenium/hub
ports: ["4444:4444"]
selenium_firefox_node:
image: selenium/node-firefox
links:
- selenium_hub
产生相同的错误。
我在做什么错了?
推荐答案
selenium_hub:
image: selenium/hub
ports: ["4444:4444"]
selenium_firefox_node:
image: selenium/node-firefox
links:
- "selenium_hub:hub"
k0pernikus的答案确实有效,我只是想详细说明它失败的原因。
While k0pernikus' answer does work, I just wanted to elaborate on the reason why it was failing.
节点容器希望连接到可简单解决的集线器:
The node containers expect to connect to a hub which is resolvable as simply:
hub
而不是在他们的示例中将其解析为:
rather than in their example where it will be resolvable as:
selenium_hub
这篇关于如何通过docker-compose而不是使用docker启动Selenium Hub和一个链接的节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!