top of page

LearningMilestone by Anuradha Agarwal is a one-stop place for coding classes for kids and workshops for teachers and parents and self-paced courses, a blog for everyone to learn python programming with a personalized approach by an experienced instructor with a decade of experience in the software industry.

  • Writer's pictureAnuradha Agarwal

Docker for Testers: Setup Docker-Compose on Linux & run container

In this post, I will be taking you through end to end steps to set up Docker-Compose on Linux machine.

To visit more such posts, follow: #TestEnvironment

Docker-Compose is a tool to define & run multiple containers in one go. It uses a configuration file in YAML format. This file defines details like image, volume, network, port etc. for each app container which is to be run. Using this file, docker-compose can bring multiple containers up in one go for one app at a time.

Docker-compose can be used in case you want to bring up several applications together each of them in a separate isolated environment. These applications can interact with each other through exposed ports and can form a complete stack solution.

For example, a complete performance testing solution stack includes a performance test tool (preferably in a distributed environment), influxDB & Grafana.

Another example is setting up an environment for the selenium grid with multiple containers with different node types.

Installing these by docker makes life easy but gets harder as we need to bring up more containers one by one. With Docker-Compose, we can bring all these apps up in one go. They run in their own container & communicate using an exposed port.

Let's setup docker-compose. This post assumes that you have a Linux instance set and also a docker installed. If that's not the case, visit post under the previous milestone step.



Step 1 - Download the Docker Compose binary Step 2 - Apply executable permissions to the binary Step 3 - Test the installation Step 4 - Create example selenium docker-compose.yml file & Validate Step 5 - Run containers using docker-compose Step 6 - View containers using docker

Step 7 - Stop containers using docker-compose

Step 8 - Scale-up using docker-compose

  • Download the Docker Compose binary for stable release using the curl command :

Run below command to give executable permissions:

Use below command to verify:

  • On your local machine, create a file named docker-compose.yml( we will SCP this file to Linux machine. In case you wish, you can directly create this file on Linux machine using vim editor.)

  • Copy the below content to your file. This contains a description of 2 services which you want to bring up.

  • On Linux instance, create directory

  • Go to the above directory and give touch command to create docker-compose.yml

touch docker-compose.yml
  • Open vim editor to copy this content taken from selenium official GitHub repository(and further modified to make it simple). You can also create this file locally and do WinSCP.

version: "3"
    image: selenium/hub:latest
      - "4444:4444"

    image: selenium/node-chrome:latest
      - /home/ec2-user/selenium:/mnt/selenium
    image: selenium/node-firefox:latest
      - /home/ec2-user/selenium:/mnt/selenium
  • Give below command to validate the contents of the docker-compose file. If there is no syntax issue, it would give the content of the file as output.

         docker-compose config

  • Give below command to get all containers up in one go. It will pull all the images and run containers

docker-compose up

Run below command to see running containers:

docker ps

Run below command to see all containers:

docker ps -a
  • Go to the location where docker-compose is available.

  • Stop all the containers in one go

docker-compose down

  • In case you wish to run multiple containers of particular service, give the command

docker-compose up -d --scale <servicename>=numberofcontainers


Congratulations you have achieved your first milestone to run a container using docker-compose!

187 views0 comments

Recent Posts

See All


bottom of page