Using Docker Containers to Test Microservices
Katty Polyak
Posted on July 16, 2020
Cover photo credit: Docker 101: Introduction to Docker webinar recap by Jenny Fong
What are Docker Containers?
Each Docker Container is essentially an isolated software-defined environment. Containers are used to help solve the problem of “Well it works on my machine.” Prior to the rise in popularity of containers, developers were using Virtual Machines to test code in a consistent environment. Virtual machines are similar to containers, as they contain an application and its dependencies, but additionally include a guest operating system and require a Hypervisor.
Image credit: Virtual Machines vs Docker Containers - Dive Into Docker by Nick Janetakis
While Virtual Machines offer a lot of benefits, they are slower to boot up than containers because of the added cost of running an operating system in each virtual machine. Though Docker is not the first company to offer a tool for containerization, it seems to have come at the right time (2013). Developers were looking for an alternative to Virtual Machines as DevOps and the Microservices architecture rose in popularity. Docker containers meet that need and are supported in a lot of other third-party applications and services (AWS, Travis CI, Jenkins, etc.).
How can they be used with microservices?
Docker containers are useful for microservices because they offer an isolated and uniform environment for each microservice to run in and can be spun up quickly. This is useful for microservice based applications because they rely on several independent running processes. If one of the microservices goes down, it does not bring down the whole application and can easily be replaced with another container running the same microservice.
What tools exist for working with Docker Containers?
There are quite a few developer tools available for working with Docker Containers. One of the most popular solutions is Docker Compose. Docker Compose uses a .yml to define a multi-container configuration. This Docker Compose .yml file is used to spin up multiple containers at one time. This simplifies the process of running and testing your Microservices application.
How can you use containers on your development machine to test your code?
Currently, Docker Compose is one of the most popular options for spinning up multiple containers locally. However, because each docker image must be built from a Dockerfile, developers who want to use Docker Compose to spin up containers locally must recreate the docker images each time there are changes to code for a given microservice. When working with teams of many developers who may not work on every repository daily, it can become tedious to make sure that they are testing local code against the most recent versions of the other microservices that rely on that microservice.
DockerLocal is an Electron application that aims to fill this need for a way to dynamically create docker compose files. Once developers sign in with Github, DockerLocal allows developers to create projects for each microservice application they are working on. Developers can then choose the github repositories associated with that project to clone the latest version of each repository. DockerLocal then creates a Docker Compose .yml file with only the microservices you’re not currently working on locally. DockerLocal is launching today and is available for download and contributions here. Have any feedback? Let us know in the comments below.
Co-authored by Katty Polyak and Vivian Cermeno
Posted on July 16, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.