Skip to main content

Virtualization vs Containerization

·6 mins·
Guide Virtualization Server Docker
Table of Contents

Useful links#

Container Engins

Docker: https://www.docker.com/get-started/

Kubernetes: https://kubernetes.io/

Podman: https://podman.io/

Container GUI Tools

Rancher: https://www.rancher.com/

Longhorn: https://longhorn.io/

Portainer: https://www.portainer.io/

Hypervisor

What is KVM: https://www.redhat.com/en/topics/virtualization/what-is-KVM

Virtmanager: https://virt-manager.org/

Qemu: https://www.qemu.org/

XEN: https://xenproject.org/

Proxmox: https://www.proxmox.com/en/products/proxmox-virtual-environment/overview

What is virtualization?
#

Before we start talking about the differences and when to use what, we first need to clarify what a VM is.

The TLDR version, otherwise it’s too long, is that virtual machines are operating systems that run on other operating systems.

You can read more here

https://www.redhat.com/en/topics/virtualization/what-is-a-virtual-machine

Why do we virtualize?
#

The sense for this was not really there in the past because all the servers back then utilized all the hardware and therefore hardware only ever did one thing.

Nowadays, however, hardware has become incredibly powerful and therefore some services only use a fraction of the hardware and it would therefore be a total waste not to run several servers on one.

What is the difference between VMs and containers?
#

At first here is a graphic that shows how VMs and containers roughly look like.

image

The difference is small but there are definitely some. Here is a table that briefly summarizes the most importent ones:

TopicHypervisorContainer
KernelHas its own kernelShares the kernel with the host
Start speedSlow because the VM has to start its kernel and more OS components have to be loaded because it is a full OSFast as the kernel is already started by the host and far fewer OS components need to be loaded as it has just enough to run one service
Resource utilizationHigh because it has to load a full OSLittle as it only performs one service
ScalabilityIt is less flexible because changes must be stored in the VM disk. Therefore, centralized storage is difficult to implement.Very good as all data is available in the container for the service. Changes are stored in volumes and can be centralized so that all containers use the same data.

Container
#

Advantages and disadvantages of containers
#

Some things have already been addressed in the table, but not everything.

Containers have the great advantage that they require extremely few resources and run the same on all servers. The phrase “But it runs on my device” is therefore solved with containers.

One disadvantage however, is the kernel. Because if you use a cluster and want to migrate a container from one server to another, this is not seamless. Because it first has to be shut down and only then can it be migrated. This actually makes sence because it uses the kernel of the host and then has to use the kernel of the new host. A VM does not have this problem as it has its own kernel.

Where do you use containers
#

Containers have a specific purpose, namely microservices. So they have one service and nothing more.

For example, a container can be a database and nothing more, another container can be a chat application and then communicate with the database container to store the data.

This sounds unnecessary at first, but the advantage is that if the database server is busy, the same container can be started on another server in seconds so that the load is shared.

Container Engins
#

There are not so many container engines that are popular but here are 3 Recommendations.

Docker
#

Docker is the standard in the industry. However, I recommend using Portainer because it is easier to manage the containers that way

Docker: https://www.docker.com/get-started/

Portainer: https://www.portainer.io/

Podman
#

Podman is a container engine developed by Redhat. The difference to docker is that it is agentless.

Docker uses a Systemd service which is the Docker Deamon to manage the containers. This runs with the root user. Which can lead to security problems if this service is hacked.

Podman containers are instead managed with shell commands without root.

Podman: https://podman.io/

Kubernetes
#

Kubernetes needs its own guide as it is incredibly complex. But in short, it is an orchestrator for the mass management of containers across servers. So it makes sense if you have services that require high availability.

A very good graphical manager for Kubernetes is Rancher in combination with Longhorn

Kubernetes: https://kubernetes.io/

Rancher: https://www.rancher.com/

Longhorn: https://longhorn.io/

Virtual Machines
#

Advantages and disadvantages of vms
#

Virtual machines have the advantage that they can do everything a normal PC or server can do. They are therefore very flexible in what they can do.

Unlike containers, they can also use hardware to extend their functions.

The disadvantage is the high load on the host as a complete OS must always be running, even for small services. Updating can therefore also be annoying as a complete update of the OS has to be made and not just a new container image that has to be pulled.

Where do you use vms
#

They always make sense if you cannot implement the service in a container, be it as a desktop or a machine that has to perform many services simultaneously or if you need to use hardware in a VM.

It also makes sense to use a VM for old operating systems.

Types of hypervisors
#

There are several types of hypervisors, as always I will only refer to the open source versions so that you can use them yourself.

You could go into more detail here about Hypervisor Type 1 and Hypervisor Type 2, but nowadays the difference is almost non-existent. Hypervisor type 1 had the advantage of being able to pass hardware from the host to the VM. Hypervisor type 2 can now also do this and therefore, in my opinion, there is no longer really a difference.

All the hypervisors I list here only run on Linux. Windows also has one, but it is not open source and the Linux ones are the best hypervisors on the market.

Virtmanager
#

Virtmanager is the best choice in my opinion if you want to do a lot with a VM on an Desktop. It is a type 2 but can still pass hardware to the VM and a lot more.

Virtmanager: https://virt-manager.org/

Qemu
#

Qemu is practical if you want to start a VM quickly and test something. Qemu has many templates which can be used to start VMs in seconds.

Qemu: https://www.qemu.org/

XEN is an old hypervisor but the most secure one on the market. Qubes OS and TrueNAS use it, as do some car manufacturers in their cars.

However, it is slower than modern hypervisors. But if security is your first priority you should use it.

XEN: https://xenproject.org/

I have written about Proxmox before, it is the best hypervisor if you need a cluster server.

Proxmox: https://www.proxmox.com/en/products/proxmox-virtual-environment/overview

Support me
#

I hope this guide has helped you a lot. I would be very happy if you would join my Patreon or donate with Paypal. I am grateful for any support.

Thank you very much for reading and for your time.

support me on Patreon.
Donate via Paypal.

If you like to share this artikel click the icons below.

Related

How to Install Navidrome?
·4 mins
Guide Server Selfhost Music
Do you always wanted to have your own music streaming service? Then this guide is for you. Here I explain how to install Navidrome and what you need to consider.
The Best Starter Guide for Browser Security
·8 mins
Guide Security Browser
Have you always wondered what actually makes a browser secure or what security actually looks like for a browser? Here you will learn this and also how you can protect yourself.
You Should Learn How to use the Terminal in Linux
·4 mins
Guide Linux Terminal
If you use linux you know the felling. The terminal is lurking in the corner waiting for the moment when you have no choice but to use it. But fear not, the terminal is easier to use than you think.
Password Managers Which Should Be Used?
·5 mins
Guide Security
Password managers are more important than ever. But which one exactly should you use? This and more is explained here.
Console Emulation Starter Guide
·6 mins
Guide Emulation Gamming
What are emulators and which ones should you use? This and more is covered here.
The Ultimate Portainer Starter Guide
·5 mins
Guide Portainer
From Installing Portainer to its configs.