Virtual Machines and Containers are two different virtualization technology. In this lesson, we will compare container vs virtual machine. We will firstly start with what is a virtual machine (VM). After that will learn what is a container. Lastly, we will do a comparison as container vs virtual machine to learn the similarities and the differences between these two virtualization technologies.
Table of Contents
In physical IT world, we use physical machines for years. But with the increase of used devices in Information Technology, using a new technology became inevitable. This new technology is virtualization. With this technology, we can use the virtual version of our previous physical machines. These are called Virtual Machines.
So, what is a Virtual Machine? A virtual machine is basically a software emulation of a physical device. From the point of user’s view, there is nothing change. They use the same CPU, the same memory etc. The only difference is, there is no multiple physical devices for each device. Instead, virtualization use multiple virtual machines under a physical machine or software.
Virtual Machines are created with a software. The name of this software is Hypervisor. There are different Hypervisor brands in IT world. Some of them are given below:
You can test yourself with Network Questions and Answers!
Now let’s compare a physical device and a virtual device. For example, we have a physical server and a virtual server. The other name of the physical server is called bare-metal server.
As you see below, in bare-metal server, we use the classic architecture. We have physical device on which we use an operating system. On this operating system, we have our file systems and we build applications on this file system.
On Virtualized Server part, this is a little different. This time, we us Hypervisor instead of Operating System. Hypervisor is the software that we will create our virtual machines. On this Hypervisor, we can create separate operating systems, file systems and applications. How an efficient system. Isn’t it?
Another virtualization technique is containers. Containers has some similarities with virtual machines but in real they are different environments. Containers achieves OS-level virtualization.
In container virtualization technique, all containers share the same kernel of the host. It is different than virtual machine technology that use separate operating systems. Using such a system provides a better boot up. So, container boot up earlier than virtual machines. They boot up in seconds.
Beside these differences, containers have also some other advantages if we compare with virtual machines. For example, containers have better performance. They also boot quickly in seconds.
Container images are small and we can use more containers in a device if we compare it with virtual machines. This number can be from 100 to 1000 for containers.
What are the common container software? You can find the most popular container software below:
As we have mentioned before, virtual machines and containers are different environments. So, what are the differences of these technologies? Here, we will compare virtual machine (VM) and container.
First of all, virtual machines are heavyweight and containers are lightweight.
Secondly, each virtual machine needs a separate operating system and has its own OS. On the other hand, containers share one host operating system that can be used together. Here, Virtual Machines have guest operating system in which there are many unnecessary parts for user. Containers share the resources of the existing operating systems instead of wasting it.
The third difference is about boot time. Virtual machines are slower than containers at the beginning. Because it takes some time to load the operating system of the virtual machine. It takes minutes. For container, there is no such time. In seconds, containers are ready to use.
About performance, containers are better. Virtual machines work with limited performance while containers work with native performance.
The other difference is about images sizes. Virtual machine image sizes are larger than container image size.
Virtual machines use required more memory while containers use less memory.
About density, containers have advantage. In a virtual machine, there can be 10 to 100 virtual machines while, this number increase from 100 to 1000 as containers.
Lastly, virtual machines are fully isolated machine which provide more security. But containers provide process level isolation. So, they are more vulnerable to attacks. We can say that virtual machines are more secure than containers.