Can we leverage Docker for implementing Selenium Grid ? Answer is Yes.

What are other options for implementing Selenium Grid

Option 1:

Consider running multiple actual(physical) machines and then running selenium tests on it in parallel using Selenium GRID. This is old school and legacy – no one is probably using it currently

Option 2:

Consider running multiple Virtual machines and then running selenium tests on it in parallel using Selenium Grid. Most of the organizations are currently using this option for their Selenium Grid implementations. Cloud implementations also are using some form of a VM

Option 3: Leveraging Docker for implementing Selenium Grid

In this option, we run multiple Containers(Docker) and then run selenium tests on it in parallel using Selenium Grid. This looks the best possible option in today’s scenario

To see how is this the best option, we would have to understand what docker is and what is the difference between docker and a VM and advantages of containers over a VM.

What is Docker

Docker is the company driving the container movement and the only container platform provider to address every application across the hybrid cloud. It is also the name of a software handling Containers on Linux and the name of the software which handles containers on Windows. (Reference https://www.docker.com/what-docker)

To explain what is container let us look at a situation where two applications with same name with the same folder structure are running on the same operating system say Windows. Applications may be in conflict with each other. When we run our application on the computer we stand a chance to have it conflict with everything else that is running on the computer.

With a container we achieve a higher level of isolation.

Each container has its own

file system,

its own registry,

its own network layer with its own published ports,

and of course its own memory space –

kind of like a virtual machine, just without the fat guest operating system.

The container is also almost instant on, when you run a container it doesn’t have to perform all kind of initialization’s like a normal computer.

A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure (reference https://www.docker.com/what-docker )

Difference between Virtual Machines and Containers

VM’s and Containers primary difference is in the way the virtualization works. VM virtualizes the hardware, thus allowing multiple OS instances to run on a single hardware machine. Where as containers provide a way to virtualize an OS in order for multiple workloads to run on a single OS instance.

This also helps in increased speed, agility and portability for a container. We can also run many more containers in a single machine then we can run a VM