Why Docker
Docker is a popular containerization technology that allows you to package an application with its dependencies into a lightweight and portable container.
From the official Docker's website:
“A container is a sandboxed process on your machine that is isolated from all other processes on the host machine”
As a QA engineer, this should make a lot of sense, and should be more than enough to understand why the use of Docker, or containers, is so popular. We are used to creating sandbox environments in order to test code and applications, to prevent external factors to affect our tests.
Is a dream come true for testers, an easy to deploy and maintain on demand environment, that is clean and that we can easily share with developers and other testers to easily reproduce defects, test workflows, and break the application without affecting other people.
Other benefits include:
Portability: With Docker, you can package your application and its dependencies into a container that can run on any platform, whether it's a developer's machine or a production server. No more configuration issues!
Consistency: Docker containers ensure that the application runs consistently across different environments, regardless of the underlying operating system or infrastructure. Sayonara "works on my machine" problem.
Isolation: Docker containers provide a high degree of isolation between the application and its host system. This means that you can run multiple containers on the same machine without worrying about conflicts between different applications or dependencies.
Efficiency: Docker containers are lightweight and consume minimal resources, making them ideal for running multiple instances of an application on a single machine or a cluster of machines.
Additionally, testers can use Docker to automate the deployment of their testing infrastructure, making it easier to manage and maintain.
Finally, with Docker, testers can collaborate more effectively with developers, as they can easily share container images and reproduce issues in a consistent environment.
In summary, Docker is a valuable tool for developers and testers alike. It provides a portable, consistent, and efficient way to package and deploy applications, making it easier to develop, test, and deploy software. As such, QA testers who learn how to use Docker can streamline their testing process and collaborate more effectively with developers.
In this post we are going to prepare the bases for the creation of our own virtual lab, using Dockers and WSL. The only prerequisite is to have a Windows 10 version 2004, build 19041 or higher, or Windows 11.
For the purpose of this tutorial, we are going to assume we do 🙂
We are going to prepare the following:
Open PowerShell in administrator mode, and enter the following command to install WSL. Restart your machine after that.
Install a Linux distribution, you have many options. Using wsl --list --online we can check what distributions are available for us:
And then install using wsl --install -d < Distribution Name >
Upgrading to WSL 2 By default, new installations will be set to WSL 2. To check this, we can use wsl -l -v
In case we have a WSL 1, we can change version using wsl --set-version < Distribution Name > 2
access using wsl (if is the default) Great! we are inside our Linux distribution, inside Windows!!
You Docker Desktop should look like this:
To verify everything is fine, inside your WSL enter docker and you should be able to see all the options to run the command:
Note: In this and all the following tutorials, we were going to use VSCode as our editor. We can quickly use to work with a remove server in the Linux distro. We can access it using, inside our Linux distro:
After we successfully installed WSL 2 and Docker Desktop, we can start playing around. This in not going to be a deep Docker or WSL tutorial, but I will be explaining a few concepts at the time we complete the steps.
A few things to have in mind while we work with Docker:
We are going to install NGINX in a Linux distribution, to use as a web server.
Congratulations!! You just ran a docker image running a web server. To stop the image we can use docker stop webserver to save resources.
That's all for now. In our next Docker tutorial, we will set up a more interesting web page in our web server, and prepare another container where we will install Mocha and Chai, to start our Automation Lab.