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

2024-04-05

我可以通过以下方式启动硒集线器图像:

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 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 up我收到消息:

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

产生相同的错误。

我究竟做错了什么?


附带说明一下,如果使用 docker-compose 版本 2 格式,则必须指定几个环境变量,否则节点将无法连接到集线器:

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

学分:容器未与 docker-compose 版本 2 链接 https://stackoverflow.com/questions/36087173/containers-are-not-linked-with-docker-compose-version-2

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

随机推荐