如何通过docker-compose而不是使用docker启动selenium hub和一个链接节点?

我可以通过以下方式启动硒中心图像:

docker run --rm=true -P -p 4444:4444  --name selenium-hub selenium/hub

并通过以下方式添加firefox worker:

docker run --rm=true --link selenium-hub:hub selenium/node-firefox

继续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

然而在运行docker-compose之后我得到了消息:

selenium_firefox_node_1 | Not linked with a running Hub container
selenium_firefox_node_1 exited with code 1

因此网格不显示任何节点.

我以为我可能会以错误的顺序进行链接,但是:

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’ answer确实有效,但我只是想详细说明它失败的原因.

节点容器希望连接到一个可以简单解析的集线器:

hub

而不是在他们的例子中,它将被解析为:

selenium_hub

相关文章

最近一直在开发Apworks框架的案例代码,同时也在一起修复Apw...
最近每天都在空闲时间努力编写Apworks框架的案例代码WeText。...
在《Kubernetes中分布式存储Rook-Ceph部署快速演练》文章中,...
最近在项目中有涉及到Kubernetes的分布式存储部分的内容,也...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...