Pages

Friday, April 5, 2019

A conceptual start to containerization


Containerization vs virtualization; Why containerization?

Containerization is the next level of primitive virtualization. In virtualization, we used to create virtual instance of computers where every instance will have it’s very own operating system, necessary libraries and other processes(programs), access to certain amount of memory, disk, CPU of host machine. But why we need virtualization? Suppose, you have a computer or server of 16 GB memory that has Windows Server installed. The hosted application doesn’t need more than 6 GB of memory in the worst case. Now you got another application that requires 8-10 GB of memory and needs to be hosted on Redhat machine. Again, in another scenario, you want separate server for staging and production environment or you need java 7 and java 8 environment. What will you do? Will you purchase machines of required configurations? Of course you can do that. But won’t it be waste of money and resources? Yes, obviously! You got resources required but they are unused and idle! The process virtualization came to address this problem.

The process includes installation of an abstract layer on top of your host machine which will be in charge of allocation and isolation of resources (CPU, RAM, Hard disk) among virtual machines. The word Isolation in this context means one machine is completely isolated from others (host and guest or virtual machines) , no process intervention, if one crashed (Virtual machines only), it won’t affect others. This abstract layer is known as hypervisor.
                 
 
Type 1 hypervisor
Type 2 hypervisor

There are two types of hypervisor available. The type 1 or bare metal hypervisor runs directly on top of your host machines hardware;no host OS is required. Type 2 hypervisor or hosted hypervisor is installed on top of a host OS. We’re not going deep of virtualization as our main concern is containerization.

Why not virtualization?

The question may arise, what’s wrong with virtualization? Why containerization came under spotlight? The answer is pretty straight forward, virtualization doesn’t have one problem but many. First of all, why we need to install full copy of OS for every virtual machines? To run a process(application or program), we don’t need a full copy of OS , what we only need is access to the kernel of OS and some required bins/libraries that are needed to run our application. Another ridiculous problem with virtual machine is boot time as it has to boot up with a full copy of OS. It may rise a serious availability issue when dealing with microservices.



Containerization
Containerization exactly aims these issues. Now we can virtualize process rather than machine. Containerization starts with installing a container runtime engine over host OS. On top of that runtime engine we can run our applications by adding necessary layers of bins/libraries. Container runtime engine kind of gives an impression to the applications that they have OS kernel available, so they only should expect needed bins/libraries to run. Where we will put these instruction and how, we will get acknowledged later.Before that we must have a clear conceptual understanding on virtualization and containerization.

Container Runtime Engine


The two mostly known container runtime engines are docker and rocket. We are going to drive deep into docker as it has been the most used one. In brief, docker engine (runtime engine) is nothing but a set of programs that are needed, to run process (application) on top of host OS. In order to understand the features that a container runtime engine provides, we need to understand the concept of image and container.

What is image and container

In one sentence, an image is nothing but a result o f a file that contains instructions to run an application. What these instruction contains are the installation of bins/libraries that are required to run an application and the application itself. 

Let’s understand these in a whole different way. Suppose your mom is out of home and she sent you a text, where she had written the whole process of cocking a dish like following,

-> Take a pot
-> Pour some water from water purifier
-> Boil for 30 minutes
-> Take the mixture from the freeze and pour it on the boiled water
-> Boil for another 10 minutes
-> Send me a message when you are done

Look at the recipe your mom had given to you. If you want to cock the particular dish you cannot but follow these instructions serially or you will not get the same result.


A file that results in image is like your mom’s recipe. In case of docker, this file is known as Dockerfile. From an docker image you can run as many as processes(application) as you want within your machines capacity. Each process(application) is known as container of an image. You can relate this with your operating system disk that you use to install OS on your computer. The disk you use is nothing but the image of a particular OS and when you install OS on your computer , you actually create an instance of that OS on your machine. In the OOP world, we may call an image a class and containers are it’s objects.

!hastaLaVista



You may follow me on LinkedIn, Github, facebook



6 comments:

  1. Good article. Helped me a lot understanding containerization. Please write more

    ReplyDelete
  2. I look forward to your writing.Good Job done.

    ReplyDelete
  3. Informative, good enough to know basics of containerization.

    ReplyDelete
  4. Well done bro. Amazingly explained in a short and interesting way

    ReplyDelete