Create a Selenium Grid with docker-compose
The latest release of Docker for Mac and Windows no longer use VirtualBox, so it has never been so easy to spinup lightweight docker containers.
Recently I needed to run some tests using Selenium grid. With docker-compose it was as easy to run them on my local box, as on the continuous integration server.
Once you have installed docker, create a new file called selenium-grid.yml:
The “depends_on” is not as clever as it looks. It only waits until the container has started, not the process inside. The node will, however, poll the host on the address until it is available.
Spin up the host and one node to begin with:
You should then be able to view the hub at http://localhost:4444. Use docker-compose to scale nodes as required:
And finally tear-down the grid with: