Are you confused over whether you should be using virtual machines or containers?
Well, I'm Don Pezet entertainer at ITProTV
And in this VS video, I'm going to show you the differences
between virtual machines and containers.
Virtual machines and containers can be confusing,
partly because there's so many players in the space.
In the world of virtual machines, we have players like Xen and KVM,
the largest open source virtualization platforms.
We have VMware, vSphere, Microsoft Hyper V, Oracle's Virtual Box.
over on the container side,
well, we have Docker who's, the undisputable champion right now.
But we also have Rocket, LXC.
Even Microsoft Windows has their own container platform.
So, how do we know which one to use?
Well, before we pick, let's start with making sure
we understand exactly what their purpose is.
I've got a little analogy I want to share with you.
Virtual Machines are based on this idea of virtualization,
which is very much like carpooling.
When I drove to work this morning, I drove my car,
I have five seats in the car.
I occupied one. I wasted 80% of the capacity of my car.
With virtualization, we put more than one workload on the same piece
of hardware to maximize the resource utilization.
I could have fit four more people in my car.
Five of us could have driven, well, from my house to here, right?
We kind of expect a somewhat common workload.
With containers, it's different.
When I drive, I might drive a motorcycle, a car, a semi truck,
all three drive different ways,
I have to have different licenses for each one.
Containers make them drive the same way.
I can actually hop onto a motorcycle, onto a car, onto a semi truck
and be able to drive it because containers hide all the complexity underneath
and give me a common set of controls that I use to steer and drive the vehicle.
Now, let's say we're having to pick between one and another.
Let's talk about how they work to understand where the efficiencies are.
With virtual machines, think of that carpool analogy,
we have multiple operating systems running on one piece of hardware.
We have our hardware, and we have some a host operating system
that acts as a hypervisor.
It's like a traffic cop determining who gets access to hardware when.
On top of that, we have partitions.
In each partition, we install a full operating system with any binaries,
and libraries, and ultimately, the applications we want to run.
Each partition has its own completely separate operating system
all running on top of that shared hypervisor.
Containers are a little bit different.
We still have hardware, we still have some kind of host operating system.
But instead of a hypervisor, we have a Container Engine.
And what that Container Engine is doing is exposing parts
of the host operating system into the partitions.
The partitions only contain the binaries and libraries,
the applications that we need.
They don't contain an entire operating system,
They don't have to. They can share the kernel
of the underlying operating system.
By having a little bit of shared resources like that
we lose the separation and independence,
but we gain a ton of efficiency.
And that's where containers become really powerful.
Let's talk about some of the other differences
between virtual machines and containers.
When we talk about startup time,
virtual machines have an entire copy of an operating system
that takes time to boot.
It can take a minute or two to boot up
and then get customized and up and operational in an environment.
Virtual Machines are great for on prem deployments and uses like that.
But in the cloud, they can be a little sluggish.
Containers, on the other hand, just contain the applications.
They're running off of a kernel that's already running.
They boot up in milliseconds, that makes them very rapid to deploy,
which is great for cloud auto scaling.
We also talk about disk space, right?
When you have an entire copy of an operating system
running in a virtual machine that's going to consume disk space.
And the more VMs you have,
the more duplicate data that you have for those (inaudible).
And that consumes extra storage.
Containers, they share, they use a container image.
they fire up with just their applications.
They're far more efficient as far as the storage they consume.
Portability.
Virtual machines can move between hardware
assuming that hardware is running the same hypervisor.
But with containers, most of the container services that are out there are compatible
with Docker containers.
That means I can write a Docker container and I know that I can run it on my laptop.
I can run it on a server here in the building.
I can run it in the AWS cloud or Microsoft Azure.
Very, very portable, very easy to move around.
We don't really have that with virtual machines.
And then just general efficiency.
Virtual machines have entire copies of operating systems
so they consume more RAM, more CPU, more disk space
Containers are far more efficient.
We're trading a little bit of isolation
in exchange for performance and efficiency gains.
And then lastly, that operating system and kernel.
I've kind of already spoiled this one a bit, right?
With virtual machines, you have dedicated operating systems
and kernels per virtual machine.
So if one VM crashes, it doesn't affect the others.
But with container platforms, they use a shared kernel.
That makes them more efficient and faster.
But if that kernel were to crash, all the containers were to go down.
Now fortunately, they're so small, I could just rapidly redeploy them
somewhere else. So that's a big bonus to have with those workloads.
Alright, so let's sum up some of the differences that we've got here.
Virtual machines give us isolated independent operating systems
that we can install applications on.
We can run different operating systems on top of the same hardware
and we can maximize our hardware utilization
in exchange for a little bit more sluggish performance.
Containers, on the other hand, are much faster.
They take less space. They deploy more rapidly
and are wonderful for auto-scaled cloud deployments.
But they leverage a shared kernel under the hood,
and that makes them a little susceptible to not being isolated
from the other containers running on the system.
Well, that's it for this vs episode.
Be sure to check out the playlist below for more VS videos,
and be sure to subscribe to our YouTube channel.
Thanks for watching.