Create the Dockerfile for the Test Container

Get introduced to the Dockerfile and its contents.

The Docker container will include everything that is needed for running the Selenium tests:

  • Operating system (Linux)
  • Automation code
  • Chrome browser
  • Maven

The container is going to be created from a Docker image, which is generated from a text file named Dockerfile.

What is a Dockerfile?

Dockerfile is a text file that describes how the container image is created.

It includes multiple commands (one per line) and is located in the project root folder.

The Selenium tests image is created in a few steps:

  • The image will be based on a pre-existing Selenium image (selenium/node-chrome).
  • The automation code is copied from the local computer to the image.
  • Maven and OpenJDK are installed in the image.
  • When the container runs, bash is started in the container.
  • After bash starts, the file executes in bash.
  • runs the mvn clean test command to execute the Selenium tests.
    The mvn clean test command runs inside of the container and executes the automation code also inside of the container.

Dockerfile content

Get hands-on with 1200+ tech skills courses.