Docker-selenium: Connecting a chrome-node in a docker container to the seleniumgrid on the local network.

Created on 14 Dec 2016  路  12Comments  路  Source: SeleniumHQ/docker-selenium

So I'm trying to connect a chrome and firefox node to my local seleniumgrid using docker.

I'm using windows 7 with docker toolbox and virtualbox. I'm not really sure what ports I need to use. Right now I use port 4444 as host and 80 as guest port for my virtual machine settings.

Via Docker-compose I try to connect the nodes to the grid URL. Here is the compose file:
`version: '2'
services:

firefox:
image: selenium/node-firefox
volumes:
- /dev/urandom:/dev/random
environment:
- NODE_MAX_INSTANCES=2
- EXTERNAL_IP=Host machine IP
- HUB_PORT_4444_TCP_ADDR=test.kpnnl.local:4444/grid/register
- HUB_PORT_4444_TCP_PORT=80
- REGISTER=TRUE

chrome:
image: selenium/node-chrome
volumes:
- /dev/urandom:/dev/random
environment:
- NODE_MAX_INSTANCES=2
- EXTERNAL_IP=Host machine IP
- HUB_PORT_4444_TCP_ADDR=test.kpnnl.local:4444/grid/register
- HUB_PORT_4444_TCP_PORT=4444:80
- REGISTER=TRUE`

The outcome is an error: Couldn't register this node: Error sending the registration request: The hub responded with 500: server error.

Does anyone know what i'm doing wrong? Thnx in advance.

Most helpful comment

try this:

hub:
  image: selenium/hub
  ports:
    - "4444:4444"
firefox:
  image: selenium/node-firefox
  links:
    - hub
  log_driver: none
chrome:
  image: selenium/node-chrome
  links:
    - hub
  log_driver: none

and then type http://localhost:4444/grid/console in your browser to check the state.

All 12 comments

HUB_PORT_4444_TCP_ADDR=test.kpnnl.local
if it's host' host name: HUB_PORT_4444_TCP_PORT=80
if it's virtual machine's host name: HUB_PORT_4444_TCP_PORT=4444

HUB_PORT_4444_TCP_ADDR should not contain the "/grid/register" bit.

that URL is calculated at runtime by this formula:
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register

therefore, you should specify:

- HUB_PORT_4444_TCP_ADDR=test.kpnnl.local
- HUB_PORT_4444_TCP_PORT=80

If port 80 doesn't work, try 4444.

Let me know if this works, and we can close it out!

I tried both and they give different errors. But it looks like 4444 is the right one but something else is off.

version: '2'
services:

chrome:
image: selenium/node-chrome
volumes:
- /grid/register
environment:
- NODE_MAX_INSTANCES=2
- EXTERNAL_IP=172.26.182.205
- NO_PROXY=test.kpnnl.local
- HUB_PORT_4444_TCP_ADDR=test.kpnnl.local
- HUB_PORT_4444_TCP_PORT=80

port80
port4444

one of two things is happening:

  1. your grid is not actually up, or misconfigured.
  2. your node doesn't have appropriate access to the hub. I'd try curling that url from the nodes. attach a terminal to one of the nodes, and attempt to curl that hub url.

I can check the grid in the browser and curl the hub url. Also ive checked to connect a node to the hub without docker and all that works. So I'm not really sure what to do.

try this:

hub:
  image: selenium/hub
  ports:
    - "4444:4444"
firefox:
  image: selenium/node-firefox
  links:
    - hub
  log_driver: none
chrome:
  image: selenium/node-chrome
  links:
    - hub
  log_driver: none

and then type http://localhost:4444/grid/console in your browser to check the state.

My application is up using docker with url xyz in ubuntu machine. Now i have configured selenium grid using docker on may local windows machine with docker toolbox. I want to know if my local docker node container will have access to xyz url or not.

@FNRG, did you try the recommendation from @chiluap?

@Janki2, it should be able to connect, did you try? Just check your networking configuration.

The following worked for me

*small modification to the work done by "Marcel Birkner" - please refer to check out his configuration here https://github.com/marcelbirkner/docker-ci-tool-stack - Thanks to Marcel for great the work!

docker-compose-selenium.yml

version: '2'
networks:
prodnetwork:
driver: bridge
services:
seleniumhub:
image: selenium/hub
ports:
- "4444:4444"
networks:
- prodnetwork
chrome:
image: selenium/node-chrome-debug
ports:
- "5900:5900"
depends_on:
- seleniumhub
environment:
- HUB_PORT_4444_TCP_ADDR=seleniumhub
- HUB_PORT_4444_TCP_PORT=4444
networks:
- prodnetwork

marking this as closed. no response for a month - assuming fixed. we can reopen if necessary :+1:

Hi, @rmanyala916 I am facing this issue in docker-compose version 3. Please check the below details and advise.

--- Chrome
INFO] Running Feature: Search by keyword
Jun 13, 2018 5:06:03 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
?[31mGiven ?[0m?[31mI am Scientist?[0m ?[90m# EbiSearchScenarioSteps.i_am_Scientist()?[0m
?[31mnet.serenitybdd.core.exceptions.SerenityManagedException: http could not be reached

--- Firefox
INFO: Using new FirefoxOptions() is preferred to DesiredCapabilities.firefox()
?[31mGiven ?[0m?[31mI am Scientist?[0m ?[90m# EbiSearchScenarioSteps.i_am_Scientist()?[0m
?[31mnet.serenitybdd.core.exceptions.SerenityManagedException: http could not be reached

yaml file as follow

version: "3"
services:
selenium-hub:
image: selenium/hub
container_name: selenium-hub
ports:

  • "4444:4444"
    chrome:
    image: selenium/node-chrome
    depends_on:
  • selenium-hub
    volumes:
  • browser_vol:/usr/src/browservolume
    environment:
  • HUB_HOST=selenium-hub
  • HUB_PORT=4444
    ports:
  • "5910:5910"
    firefox:
    image: selenium/node-firefox
    depends_on:
  • selenium-hub
    volumes:
  • browser_vol:/usr/src/browservolume
    environment:
  • HUB_HOST=selenium-hub
  • HUB_PORT=4444
    ports:
  • "5911:5911"

volumes:
browser_vol:

Should I explicitly mention the networks as above?

version: "3"
networks:

  • prodnetwork

driver: bridge

services:
selenium-hub:
image: selenium/hub
container_name: selenium-hub
networks:
- prodnetwork
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome
depends_on:
- selenium-hub
volumes:
- browser_vol:/usr/src/browservolume
networks:
- prodnetwork
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
ports:
- "5910:5910"
firefox:
image: selenium/node-firefox
depends_on:
- selenium-hub
volumes:
- browser_vol:/usr/src/browservolume
networks:
- prodnetwork
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
ports:
- "5911:5911"
volumes:
browser_vol:

networks:
prodnetwork:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Manolo2014 picture Manolo2014  路  3Comments

peterstory picture peterstory  路  4Comments

JordiGiros picture JordiGiros  路  4Comments

testphreak picture testphreak  路  6Comments

geekdave picture geekdave  路  4Comments