Microservices Dockerization

DZone 's Guide to

Microservices Dockerization

Here we explore bringing microservices and Docker together, the benefits of choosing containers over VMs, and the challenges awaiting this approach.

· Cloud Zone ·
Free Resource

This article is the continuation of my last article Distributed Application Development Through Microservices.

Image title

Docker is a world-leading CaaS (Container-as-a-Service platform). Docker is the most dominant tool in the container ecosystem at the moment. The container is a way to package software along with binaries and settings required to make the software that runs isolated on sharing an operating system. Of course, containers have a lot of benefits — along with some complications and concerns. I have listed few advantages of containers, but there are many more that are not listed here.

  1. Environment consistency: Applications running on containers behave consistently in different environments. This eliminates environmental inconsistencies and makes testing and debugging less complicated and less time-consuming.
  2. Faster deployment: A container is lightweight and starts and stops in less than a second, as they do not require any operating system boot. That eventually helps us to achieve faster deployment and high availability.
  3. Isolation: Containers running on the same machine using the same resources are isolated from each other. So, if one application crashes, it will not impact the other application.
  4. Portability: A major benefit of containers is their portability. A container wraps up an application with everything it needs to run, like configuration files and dependencies. This enables you to easily and reliably run applications on different environments, such as your local desktop, physical servers, virtual servers, testing, staging, production environments, and public or private clouds. This portability grants organizations a great amount of flexibility, speeds up the development process, and makes it easier to switch to another cloud environment or provider if need be.
  5. Scalability: A major benefit of containers is that they offer the possibility of horizontal scaling, meaning you add more identical containers within a cluster to scale out. With smart scaling, where you only run the containers needed in real time, you can reduce your resource costs drastically and accelerate your return on investment.

To better understand the container system, we have to look into the three following areas.

  1. Multiple containers: How we will manage when we have multiple containers?

  2. Multiple hosts: How we can distribute the traffic from multiple host to individual containers?

  3. Networking: How can multiple containers communicate to each other in isolation?

We can deal with above problems in different ways, but choosing the efficient way can help take advantage of containers.

Microservice architecture divides a monolithic application into components that run in their own containers and can scale-out and scale-in independently. Microservices achieve the true scalability.

And then there's running multiple containers of the same Docker image to achieve high availability. If one of the containers goes down, then other containers can be available to serve requests.

Running multiple containers and multiple copies of the same container make it hard to manage and communicate. Docker gives each container its own set of virtual network devices and a unique IP address.

You may be thinking, "Who will do and manage all this work?" No worries. The answer to all these questions is the container orchestration engine. There are different container orchestration engines like Kubernetes, Docker Swarm, and Amazon ECS. You can choose any orchestration engine to manage your container system, as an engine is not going to make any difference here.

We are extensively using AWS, so I recommend going with Amazon ECS to manage our container system, AWS Auto Scaling to manage the scaling, and AWS load balancer to manage the load and ensure high availability.

Image title

As we have learned about containers, now it's time to better understand the container concept. In our company Shortlist, we converted our monolithic application to a microservices architecture, but we were running the microservices on a Linux instance instead of container systems until last month. That was something that was really stopping us from seeing the real advantages of microservices. You can run the microservices without containers, but if you want to achieve the true scaling, low cost, faster deployment, and consistency, then the container is must use.

Microservice on VMs

Microservice on Containers


We have multiple microservices running on same Linux instance. To scale any of the services, we have to scale the whole VM instance, adding unwanted scaling of other services.

Individual applications can be scaled out independently without affecting other services.

Resource utilization

We cannot distribute the services based on resource utilization: CPU utilization, memory utilization, etc.

Container orchestration takes care of better utilization of resources and places the services based on the resources available on the host.

Faster deployment

Spinning up new VMs is slow, as it requires a system boot. If we have to scale a single service, we have to launch new VMs, which need some time reboot.

Containers, by contrast, are much smaller because they do not require the operating system spin-up time associated with a virtual machine. Containers are more efficient at initialization. Overall, containers start in seconds. That's much faster than VMs.

Cost Optimization

As we are running the services on VMs, that costs us more than compared to running the same services on container systems.

Running microservices on containers helps us to see the true advantage of microservices with lower costs.


Deploying services on new VMs means first ensuring the required software is installed on the machine.

Dockerized micr services can run in containers. You can deploy those containers to any server with Docker installed.

In my next article, we will then see the steps guide to set up containers on AWS ECS.

cloud ,docker containers ,microservices architecture ,container orchestration

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}