Virtualization: Containers vs VMs

Virtualization. What is it?

Virtualization is a technology that allows users to create multiple virtual instances on a single physical machine.

These “instances” can be different computers, servers, operating systems, applications, and even networks.

Before virtualization, if a user or company wanted to host different operating systems and its associated applications, they would need an individual physical server or computer dedicated to the specific operating systems.

They found this to be high in cost and resources. Now, virtualization addresses these issues by abstracting the underlying hardware and creating virtual environments.

There are two different types of virtualization methods: containers and virtual machines.

What is a VM?

A VM or virtual machine is an isolated instances of operating systems and applications running on top of a hypervisor.

Each VM behaves like a separate physical computer, but share the same hardware as the physical computer/server.

To build a virtual machine, you start off with hardware such as a server.

On top of this is software or a hypervisor.

A hypervisor is what allows one machine to run multiple virtual machines. It helps control the sharing of a machine’s hardware.

On top of the hypervisor is the own virtual machine with their own operating system.

On top of the operating system, there are applications that they are running.

A VM seems like a create replacement instead of having multiple physical systems, and they are, however, because of the large amount of layers that they host, they consume a lot of RAM and CPU power from the physical computer.

Additionally, they consume a lot of disk space since each VM has their own dedicated operating system.

What is a container? What is Docker?

A container is similar to a virtual machine. However, instead of having their own operating system, they only contain an application.

This application has been packaged with all the files, configurations, and dependencies that are necessary for it to run.

For example if a developer were to create a web server and wanted to host it on any other computer, they can create a container for the website by bundling it with everything it takes to host it (libraries, modules, databases, etc) and distribute it to host it on any other server.

Containers start off with a phyiscal server, then on top is an operating system. Next, instead of using a hypervisor, containers use something called a container engine. It helps unpack the container files and hands them off to the operating system kernel.

While VMs contain an entire operating system, making filesizes larger, containers share the underline operating system and only contain an application, making it smaller and lightweight/fast. Howevre, because of this the container must be packaged to work with the same operating system of the hardware. (Can’t run windows on linux and vice). Since containers share underline operating system, if the operating system crashes, all the containers go down as well.

However, because of their advantages of being lightweight, containers consume less ram and cpu power from the server than VMs. The leading application that is responsible for building containers is Docker. Docker, in short, is a platform that facilitates the development, deployment, and management of applications using containerization.

There are three things important when using Docker.

Once a repository hold code ready to be hosted, the user can create a dockerfile to build the docker image. The docker image can be read in a layer format, causing the dockerfile to consider each step as its own layer.

Once the DockerFile is created, the user can build the image using the command:

docker build -t username/imageName:version number.

The -t gives a image a name tag for easier access later.

Now, you can run the image by running the command:

docker run (container)


If the container is hosted on a webpage for example, you can use port forwarding by using the -p switch including the port numbers in the local machine and container.

What do companies use?

Companies use both Docker containers as well as virtual machines in order to meet their specific requirements based on the application of choice, workloads, and goals that they have.

VMs could host legacy applications or provide strong isolation for security tests and workloads, while containers can be used to employ microservices. Their decisions often depend on the what they can trade off in terms of isolation and resource use.