Virtual Machine, Dockers & Containers

What are the system resources? 

Memory 
I/O
Disk 
Processing 

These resources will be shared among the programs run on the computer. 

Why we need OS?

Boundary management is managing the program not to interfere with other programs memory/IO on a shared computer. This will be taken care by operating system. 

When a program runs, we reserve X amount of memory, Y amount of I/O through operating system's interface. Similarly, multiple programs take the slices of the resources that an operating system can provide, and the remaining resources are unused. 


Why we need virtual machine?

  1. App Isolation

If one of the programs uses all the memory, all other programs will be upset. 


  • At this point, we prefer to have a strong boundary which will be provided by virtual machines. Virtual machine is an operating system in itself, so it is an operating system running on top of the operating system. 


Without concerning about real operating systems, programs can connect via fake operating system (virtual machine) which has been assigned with set of resources. In this way, the app/program will be isolated with its own set of resources. 

Amazon, Google, etc., can rent the spare hardware to small industries, so these small industries can avoid the investment of maintenance and placing a computer. This forms a cloud as these small industries will not have its own computer and real operating system rather it will have only virtual machines. 


In this case, If a software crashes, it will not affect the memory, RAM and hard disk of the host operating system.  

2. Platform Independent 

  • Code doesn't need to be platform dependant while using virtual machines. It doesn't need to know that windows is running below. Multiple OS environments can exist simultaneously on the same machine, isolated from each other. For example, If I want to use Linux on top of Windows, this will be one of the best uses of virtual machine. 

3. Cost Saving 

Provisioning of these devices is quite dynamic by shutting down the machine and restarting new machine. 
Platform independence is the game changer among these. 




Taking all these into consideration, light weight OSes come into picture.  These are precursor/forerunner of  Containers. 



Containers 

Containers are the solution to the problem of how to get software to run reliably when moved from one computing environment to another. 

Containers are used for virtualization, and it isolates the app. It will not have all the features of OS, so this light weight container is built when needed and teared down when it is not needed. This is faster than booting time. 

Building and tearing down this feature is mounting and unmounting. Container requirements are specified as 'images' which are mounted on 'containers'. 



With virtualization technology, the package that can be passed around is a virtual machine, and it includes an entire operating system as well as the application. A physical server running three virtual machines would have a hypervisor and three separate operating systems running on top of it. 

By contrast, a server running three containerized applications with Docker runs a single operating system, and each container shares the operating system with Kernel with the other containers. Shared parts of the operating system are read only, while each container has its own mount (i.e., a way to access the container) for writing. That means the containers are much more lightweight and use far fewer resources than virtual machines. 

There are others needs for using virtual machine and it varies from user to user.  

Running old applications

If an application don't support on windows 10 or windows 8 but supports on windows 7, install windows 7 within virtual machine and use it, and no need to install windows 7 for an application. 

Easy to replicate

After installing the operating system in virtual machine, virtual machine can be saved as appliance. So, it can be easily copied and used on another computer. 

Creating personal cloud computer

When we forget to take the laptop but still want to connect to our laptop which is running and on, we can access the laptop using mobile via Remote Desktop Protocol (RDP) over the internet. 

Docker

Technologies like docker move the OS consideration back to the developer. The developer can actually specify these are the resources I need, and this is the operating system I'll be running on. So, no need to worry about hardware. 

Docker will create an interface to interact with hardware or virtual machine. It will create a container on top of it and let your program interact through the interface. When it needs more memory, it just asks and gets it. 

Docker provides the ability to package and run an application in a loosely isolated environment called container.

Disadvantages of Container

Containers are considered as little slow. 



References: Gaurav Sen Channel

I just combine content from various links and own research according to my needs.

Comments