Virtual Machine and Containers for Non-Techs
In last article Virtualization for Non-Techs I tried to explain virtualization with help of kitchen. If you haven't read it be sure to read it as I will be continuing from where I left in last article.
In this article I will try to explain Virtual Machine and Containers - two main virtualization technology used in industry using same kitchen analogy. So let us recap where we left last, i.e., we have a big kitchen and chefs who are expert in cooking Italian and Indian cuisine and we reached a point of time where both of them were fighting for resources even there was enough resource for both of them, so we came up with following idea of segregating them in there own smaller kitchen where then can work without interfering with each other. (There are many other benefits virtualization which I am not covering here like security etc.). This where we left last:
Now, there are two types of virtualization we mainly see in industry.
- Hardware level virtualization - Virtualbox, VMWare Player, HyperV, xhyve etc
- Containers - Docker, rtk, LXC/LXD
So let's start with Hardware Level Virtualization.
Indian and Italian are two different cuisines using different types of utensils for cooking. I am not a food expert but what I have seen in restaurants and being an Indian, I know they use different types of utensils. So hardware level virtualization comes in this place where you want to isolate a system in hardware level. Resources such as gas, water etc are available to all but according to requirement in different form. For example, Indian food require a tandoor while Italian might require pizza oven where both of them will run on gas but usability is different.
Similarly in Hardware Level Virtualization you might want to a operating system which only supports a particular type of CPU architecture (eg, x86, x86-64, ARM etc) or you want a run a software which is only supported in only a particular type of operating system then you can go for hardware level virtualization as kernels are different.
Hope I am able to explain Hardware Level Virtualization using kitchen analogy now lets move to Containers (or what I like to call them as Namespaces)
Moving away from different cuisines for explaining containers, I am considering two different cuisines inside India. Let's take Bengali and Karnataka. We share many similar things like species and other ingredients but there are difference and when we want to isolate them without interfering resources we can go for containers.
For example, both chefs will use similar utensils and ingredients but there might be difference in some of them which are not drastic as was previously. So then can be in similar environment but in isolation and their resources can easily customized without removing all chefs and everything from kitchen. Also, by best practice those isolated kitchens can have only one chef working in it. You can have multiple chefs but it defeats the purpose of having these isolation where as previously in hardware level one you can multiple chefs working in it. Due to this single chef its easy to transport these chef in different place and rebuilding kitchen for them if some accident happens it easy and fast to setup.
Containers are like this, mainly they run on Linux systems and uses common kernel on host operating system but are not allowed to view access resources of others. Their resources can be changed dynamically while they are running. Containers are not new previously Unix systems had it previously like Jails in BSD and Solaris Zones in Solaris. Also Mac being a unix system underneath it sandboxes all its application similar to containers. Windows recently introduced Windows containers cooperating with Docker. In upcoming Windows Core OS they are going for similar approach for its application where it will be sandboxed.
Here single chef refers to single process in a container, unlike Hardware Level Virtualization where it takes time to startup due to starting whole operating system and then you application will start and it hard to recreate environment as its a big piece of software. (I considering here application level container there are operating system level container which allow multiple process but are still fast than those hardware level one).
But there is problem, if you have multiple isolated kitchens how will you know how much resources they are using, how much food they produced, which is what Kubernetes do. Orchestrating those large number of containers. Which I will explain in next post/article.
Hope you like this.
Happy Learning! Happy Coding!
Stay Safe! Stay Home!