How to start selenium hub and one linked node via docker-compose instead of using docker?
As a side note, if using docker-compose version 2 format you have to specify a couple env variables, otherwise the node will not connect to the hub:
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
Credits:Containers are not linked with docker-compose version 2
Stumbling across this tutorial, there was this syntax provided. And even though it's similar to one of my approaches, it worked.
hub: image: selenium/hub ports: - "4444:4444"firefox: image: selenium/node-firefox links: - hubchrome: image: selenium/node-chrome links: - hub
It's seems to be something about the naming, yet am not sure.
selenium_hub: image: selenium/hub ports: ["4444:4444"]selenium_firefox_node: image: selenium/node-firefox links: - "selenium_hub:hub"
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