Containerization
Do not miss this exclusive book on Binary Tree Problems. Get it now for free.
In this article, we will learn about containerization, how it differs from virtual machines (system virtualization) and its benefits. Containerization and virtual machines often come up in the same breadth and this article assumes you have at least a basic idea about what virtualization is. Containerization technology has been available for decades but the industry saw a broader adoption of the technology with the emergence of Docker in 2013.
Table of Content
- What is containerization
- Difference between Containers and Virtual machines
- Benefits of containerization
What is Containerization?
Containerization is the packaging of application software code along with all its dependencies in a single unit known as(you guessed it) a container. Containers are lightweight executable units of computation that can be run anywhere. For example. Let's say we had a python application we wanted to run. To execute the app, at the very least we would need to have a version of python installed in our system. That means the python runtime is a dependency of the application, we might also have other libraries and dependencies that also need to be on our system before we could execute the app. If the python app was containerized we would be able to run it directly because it would already have all its dependencies bundled with it in its container.
Using a loose analogy to further illustrate the point, let us say you ordered a cake from two different bakeries. The first bakery delivers only your cake to you with nothing else included. If you wanted to eat the cake you would have to get a plate and perhaps a fork. Now the second bakery delivers your cake but this time it is in a cute box that also comes with a fork and a plate. The second bakery gave you all you needed to enjoy the cake, you didn't have to go get anything else you could start enjoying the cake immediately. What the second bakery did packaging the cake together with the things needed to eat the cake is what containerization is.
Difference between Containers and Virtual Machines
To fully understand containers we have to look at how they differ from virtual machines and why they are considered to be more lightweight. A Virtual machine is a form of hardware virtualisation. The Hypervisor spins up VMs which is a combination of virtual hardware and a guest OS that runs on top of it to serve applications.
For every VM we wanted to spin up it comes loaded with an OS, different binaries and dependencies needed to run the application as well as the application itself.
A container differs from a VM because we only need to package the libraries and dependencies together with the app. Containers can be seen as a form of OS-level virtualization because the containers all run on the same OS. In this way, we can even get higher efficiencies using containers because there is less overhead and we can have a lot more containers running on a single OS.
Another way that both technologies differ is that while in virtualization the hypervisor is responsible for spinning up and managing the isolated VMs on the hardware, In containerization the runtime engine which is installed on a host OS is what is responsible for managing the various containers that are running on a system. Containers are also not quite as isolated as VMs.
Containers running on a runtime engine
Benefits of Containerization
It simplifies the development process
Let's paint a scenario. You and a partner are working on developing an application. You might be using windows OS and your project partner works on a macOS. You are done with your part so you push to a remote repo, your partner pulls and wants to work on their part but the application fails, it turns out that there is a windows specific dependency that the app needs that is causing the conflict. So now we are experiencing a problem simply because we do not share a uniform development environment. Containerization solves this because instead of working on our native OS environments. We bundle the application and its dependencies in a container and as long as each person has the runtime engine installed on their system we can develop inside of that container regardless of the OS. Now you and your partner can work in a uniform environment and avoid dependency conflicts.
Works well with microservice architecture
Microservice architecture can be described as the breaking down of highly coupled and complex applications running on single servers into modular specialized services that are loosely coupled and communicate with each other via exposed APIs. Since Containers are so modular and flexible they are the perfect candidates for shipping microservices. The portability of containers also ensures that we can scale our microservices. For example, let us say we had a javascript microservice that handled one part of our business logic and a python microservice that communicated with the js service. Now our application became bigger and the js service started receiving way more traffic. Scaling to accommodate this new traffic is as easy as spinning up as many more containers of that js service as needed and balancing requests among them.
Fast and Streamlined Deployments
Deploying applications to production is quick and easy if we utilize containers. The ability for containers to run on any platform assures us of a stress-free deployment cycle. We do not have to waste time configuring our production environment and application to ensure everything is compatible and that they play nice together.
Conclusion
Containerization is a core concept in system design and modern software architecture. It is also important to note that virtualization and containerization are not competing technologies. Each technology has its use case and most of the time companies utilise both i.e running multiple containers on multiple VMs to get even better efficiency.
Sign up for FREE 3 months of Amazon Music. YOU MUST NOT MISS.