Introduction
this is part 2 from the journey it's a long journey(360 day) so go please check part 1 , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.
What is virtual machine?
Let's take an example we have a machine running mainly mac OS , let's say I see an app that run only on windows .
So should I go and buy a new PC for this ? simply no , you can install an vm tool such as vagrant , virtualbox , vmware ...
vm tool let you run an image of an Operation System on top of your existing OS without colliding two OS togetger.
it run on a layer called Hypervisor which is divided to 2 parts , part 1 run directly on your physical hardware (such as v-hyper) and run on virtual hardware (such as vmware , virtualbox).
Virtual Machines and apps
let's say we need to run 4 apps on our server , every app should be in his own VM , every VM os size vary let's say it will take 800 MB/App for just a fresh install , so with simple Math 800*4 = 3200 MB ~= 3 GB .
that's a lot of space as we see , even when they are fresh OS nothing installed on them.
we talk about space what about resources such as CPU and ram ?
basically every VM will take resources from the server which is a big waste and cost more money.
Docker...
Here came the role of Docker so he help with this problem there is no os layer here as we see in the picture it run on Docker Daemon directly so it doesn't take a huge space or resources and can run quite fast in milliseconds.
each App here is called an container , every container have his own setup and they are lightweight so we save resources.
We can control them using docker to communicate with those containers.
Which is The best then?
simply use a VM when you need to isolate a complete system (example each customer get an vm) and Docker to isolate apps.