Here’s simple guide to setup a minimal Selenium Grid with Docker. For running Docker on your machine you will need Docker toolbox installed from https://www.docker.com/products/docker-toolbox. Below steps are done on a Mac.
We will use Hub and Node images from Selenium project hosted at Docker Hub https://hub.docker.com/r/selenium/
Next we need to create a docker-compose file describing how we want to run the Selenium Grid Hub and connect nodes to the Hub. In this example we will launch a multi-container setup with a Hub connected to Firefox and Chrome nodes:
If you don’t have Docker running, then start the Docker daemon with default machine by using following command:
docker-machine start default
To connect to the Docker shell run following command:
eval $(docker-machine env)
This will connect the terminal session to the Docker shell
Finally run the docker-compose command from the directory where docker-compose.yml file is stored:
This will get required images from the Docker hub and launch the Hub node followed by Firefox and Chrome nodes which will be registered to the Hub. Now we have a minimal Selenium Grid up and running. We can point Selenium tests to this Grid for execution. In the next post we’ll see some advanced options and integration with Maven and Cloud tools.