我尝试用java-docker lib启动Selenium节点Docker容器,结果是节点没有链接到集线器
container = dockerClient.createContainerCmd(image)
.withExposedPorts(exposedPort)
.withHostConfig(new HostConfig().withPortBindings(bindings))
.withName(name)
.withEnv("HUB_HOST=selenium-hub")
.withEnv("HUB_PORT=4444")
.exec();
dockerClient.startContainerCmd(container.getId()).exec();我正在尝试模仿我的docker-compose,如下所示:
version: '3'
services:
selenium-hub:
restart: always
image: selenium/hub:latest
ports:
- 4444:4444
chrome:
restart: always
image : selenium/node-chrome-debug:latest
ports:
- 6001:5900
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
links:
- selenium-hub:hub因此,我认为下面的内容应该涵盖docker-compose中的HUB_HOST和HUB_PORT
.withEnv("HUB_HOST=selenium-hub")
.withEnv("HUB_PORT=4444")然而,我不知道什么应该是depends_on部分的java等价物。
发布于 2019-09-24 22:41:48
首先,如果你使用的是不使用链接的docker-compose。selenium-hub:hub,所以你最好使用别名hub。
("HUB_HOST=hub")您也可以删除ENV,您可以直接使用hub主机。
在docker-compose中,容器可以引用另一个名称为container的容器,不需要内衬。
我还假设您正在从相同的docker-compose运行selenium-hub。
chrome:
restart: always
image : selenium/node-chrome-debug:latest
ports:
- 6001:5900
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444https://stackoverflow.com/questions/58082104
复制相似问题