Explaining Hardware Virtualization and Containerization
Virtualization commonly describes the abstraction of a computer resource, such as hardware, memory, storage, an operating system, a desktop machine, or a network. The abstraction is built on top of the physical resource.
There are many types of virtualization. Here, let’s look at virtualization of hardware and an operating system—also known as containerization—which improves resource utilization.
Hardware virtualization mirrors a physical machine, and it’s the most common type of virtualization. The abstract machine is called a virtual machine (VM), and it runs in parallel on the same host machine CPU. A VM could be running on a local machine or in a cloud environment.
On a local machine, hypervisor software that runs on the host machine is necessary. The VMs run on top of the hypervisor, as illustrated below.
Each VM has its own operating system, networking, and file system distinct from the host machine's and other virtual machines'. A VM operating system does not have to be the same type as the host machine’s operating system, or even the same distribution. The host machine could be running Windows, and three different VMs running on a hypervisor on the host machine could be running three different OSes. The OS running on a VM is also called a guest operating system.
A VM is typically created using a virtual machine image—a template for creating a VM. This could be a virtual hard disk (VHD), VDI, VMDK, or HDD file.
Hardware virtualization is used for several purposes:
- Running a different operating system or a different OS distribution than the host machine’s OS
- Running multiple virtual machines in parallel on a single underlying machine
- Running prepackaged software as VM images
Containerization is a relatively new type of operating system virtualization where multiple containers run on an underlying operating system (either the same one or different OSes). Containers are lightweight modules that encapsulate a section or snapshot of the underlying OS kernel.
Containerization was made mainstream by Docker a few years ago. While some other types of container implementations, such LXC and chroot, are available, Docker has become the de facto containerization platform.
Docker containers run atop a Docker Engine, which runs on the underlying operating system, as illustrated below.
On comparing this image with the fist one, Docker containerization appears to be no different than the virtual machines, but these are different types of virtualization. While each virtual machine has its own complete operating system, each Docker container doesn’t. Multiple Docker containers run in isolation on the same underlying operating system.
Each Docker container has its own networking and file system, but all Docker containers on the same Docker Engine make use of the same underlying operating system kernel. As a result, Docker containerization makes a more efficient use of the operating system resource.
Of the several types of computer resources that can be virtualized, hardware and operating systems are the most common. Hardware virtualization and containerization seem similar, but there are also differences between the two that should be understood.