Creating testing environment using Docker & GUI Based Containers, Installing & Examples Docker Compose.

Creating testing environment using Docker – 

Docker allows you to run your tests in containers as well as isolate your tests in development and deployment. 

Creating testing environment using docker

Create selenium hub container, and link it with two node containers.
One node with firefox installed, another node with chrome installed.

Tester should be able to run selenuim automation programs for testing the application on multiple browsers.

To delete all the running containers

docker rm -f $(docker ps -aq)

In Browser — open –

Search for selenium
We have a image – selenium/hub

To start selenium/hub as container

docker run –name hub -d -p 4444:4444 selenium/hub

we also have- selenium/node-chrome-debug ( It is ubuntu container with chrome)

To start it as a container and link to hub ( previous container)

docker run –name chrome -d -p 5901:5900 –link hub:selenium selenium/node-chrome-debug

we also have- selenium/node-firefox-debug

To start it as a container and link to hub ( It is ubuntu container with firefox)

docker run –name firefox -d -p 5902:5900 –link hub:selenium selenium/node-firefox-debug

To see the list of container

docker container ls

Note: firefox and chrome containers are GUI containers.

To see the GUI interface to chrome / firefox container

Download and install vnc viewer
In VNC viewer search bar
Password – secret


All the commands we learnt till date are adhoc commands.

In the previous usecase we have installed two containers ( chrome and firefox)
Lets say you need 80 containers?
Do we need to run 80 commands?

Instead of 80 commands, we can use docker compose


Docker compose
This is a feature of docker using which we can create multicontainer architecture using yaml files. This yaml file contains information about the containers that we want to launch and how they have to be linked with each other.Yaml is a file format. It is not a scripting language.
Yaml will store the data in key value pairs
Lefthand side – Key
Righthand side – Value
Yaml file is space indented.

Sample Yaml file

sunil: Devops
raj: Python
lakshmi: Devops
rani: AWS

logiclabs — root element

To validate the abvove Yaml file
Paste the above code — Go button


Installing Docker compose

1) Open
2) Go to linux section
Copy and pase the below two commands

sudo curl -L “$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

How to check docker compose is installed or not?

docker-compose –version



Lets remove all the running container

docker rm -f $(docker ps -aq)

To stop the containers

docker-compose stop

We got lot of logs coming on the screen. to avoid it we use -d option

Create a docker compose file for setting up LAMP architecture

vim docker-compose.yml

version: ‘3’

image: mysql:5

image: tomee

  • 6060:8080
  • mydb:mysql php:
    image: php
  • mydb:mysql
  • apache:tomcat


docker-compose up -d

To see the list of the containers

docker container ls

( Observation – we are unable to see the php container)

docker ps -a

Ex: Docker-compose file for setting up CI-CD Environment.
jenkins container is linked with two tomcat containers

vim docker-compose.yml

version: ‘3’
image: jenkins/jenkins

  • 7070:8080 qaserver:
    image: tomee
  • 8899:8080
  • devserver:jenkins prodserver:
    image: tomee
  • 9090:8080
  • devserver:jenkins


docker rm -f $(docker ps -aq)

docker-compose up -d

docker container ls

To check
public_ip:7070 ( To check jenkins )
public_ip:8899 ( Tomcat qa server )
public_ip:9090 ( Tomcat prod server )

Docker-compose file to set up testing environment.
selenium hub container is linked with two node containers.

vim docker-compose.yml

version: ‘3’
image: selenium/hub

  • 4444:4444 chrome:
    image: selenium/node-chrome-debug
  • 5901:5900
  • hub:selenium firefox:
    image: selenium/node-firefox-debug
  • 5902:5900
  • hub:selenium


Lets delete all the running containers

docker rm -f $(docker ps -aq)

docker-compose up -d

docker container ls

As it is GUI container,
we can access using VNC viewer

Open VNC viewer
password: secret


Leave a Comment

MFH IT Solutions (Regd No -LIN : AP-03-46-003-03147775)

Consultation & project support organization.


MFH IT Solutions (Regd)
NAD Kotha Road, Opp Bashyam School, Butchurajupalem, Jaya Prakash Nagar Visakhapatnam, Andhra Pradesh – 530027