k0p*_*kus 5 selenium docker docker-compose
我可以通过以下方式启动硒中心图像:
docker run --rm=true -P -p 4444:4444 --name selenium-hub selenium/hub
Run Code Online (Sandbox Code Playgroud)
并通过以下方式添加firefox worker:
docker run --rm=true --link selenium-hub:hub selenium/node-firefox
Run Code Online (Sandbox Code Playgroud)
继续http:// localhost:4444/grid/console然后将显示网格就好了.
我不想每次都使用docker,但通过相同的设置docker-compose.
因此,我想我可以在我的身上做到这一点docker-compose.yml:
selenium_hub:
image: selenium/hub
ports: ["4444:4444"]
links:
- selenium_firefox_worker
selenium_firefox_worker:
image: selenium/node-firefox
Run Code Online (Sandbox Code Playgroud)
然而在跑完之后docker-compose up我收到了消息:
selenium_firefox_node_1 | Not linked with a running Hub container
selenium_firefox_node_1 exited with code 1
Run Code Online (Sandbox Code Playgroud)
因此网格不显示任何节点.
我以为我可能会以错误的顺序进行链接,但是:
selenium_hub:
image: selenium/hub
ports: ["4444:4444"]
selenium_firefox_node:
image: selenium/node-firefox
links:
- selenium_hub
Run Code Online (Sandbox Code Playgroud)
产生相同的错误.
我究竟做错了什么?
作为旁注,如果使用docker-compose版本2格式,则必须指定几个env变量,否则节点将不会连接到集线器:
version: '2'
services:
hub:
image: selenium/hub
ports:
- "4444:4444"
firefox:
image: selenium/node-firefox
environment:
HUB_PORT_4444_TCP_ADDR: hub
HUB_PORT_4444_TCP_PORT: 4444
links:
- hub
Run Code Online (Sandbox Code Playgroud)
在本教程中遇到了绊脚石,提供了这种语法.即使它与我的一种方法相似,但它仍然有效.
hub:
image: selenium/hub
ports:
- "4444:4444"
firefox:
image: selenium/node-firefox
links:
- hub
chrome:
image: selenium/node-chrome
links:
- hub
Run Code Online (Sandbox Code Playgroud)
这似乎与命名有关,但我不确定.
selenium_hub:
image: selenium/hub
ports: ["4444:4444"]
selenium_firefox_node:
image: selenium/node-firefox
links:
- "selenium_hub:hub"
Run Code Online (Sandbox Code Playgroud)
虽然k0pernikus 的答案确实有效,但我只是想详细说明它失败的原因。
节点容器期望连接到一个集线器,该集线器可以简单地解析:
hub
Run Code Online (Sandbox Code Playgroud)
而不是在他们的示例中,它将被解析为:
selenium_hub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3964 次 |
| 最近记录: |