Search code examples
dockerselenium-griddocker-machine

How to access Docker Selenium hub console in browser?


I am running docker selenium hub on windows. The container is up as docker log shows. However I am confused at what is the actual hostname that the hub uses. When i use conventional Selenium hub, I can use http://localhost:4444/grid/console to check that it's running correctly. But in this case of docker, I am confused at the printing of Docker log.

I tried 0.0.0.0, localhost, 172.17.0.2 as hostname to open /grid/console in browser. None of them works.

Also when I tried to use 'netstat -a' to list all tcp connections, I do not see any of them has port 4444.

enter image description here

enter image description here

Could anyone let me know what went wrong?


Solution

  • You are running docker on windows, there are two things you can do.

    1. Map your port 4444 to host when starting the container.
    2. On windows, your container is ruining in Boot2Docker virtual machine.
      So instead of http://localhost:4444/grid/console use http://{ip of boot2docker vm}:4444/grid/console

    To get IP on boot2docker machine try the following command:

    docker-machine ip default

    Port expose docker example:

    docker run -d -p 4444:4444 --name <container-name> <image-name>