Containers vs Virtual Machines

avatar
Rafi Adinandra
Calendar icon
November 30, 2020

This is a transcript of the Tech Talk on Virtual Machines versus Containers by Tim Delesio.

You can view the video at the bottom of this blog post.

Before we jump into the topic, let’s just straight-up computing or what is also referred to as bare metal. This is just running apps on your computer. People do this every day when you boot up your Mac or PC. When someone refers to an app running as bare metal, this is really all they are referring to. Just running an app on the device directly. So, what are Virtual Machines and Containers then?

What are Virtual Machines?

There are not too many systems these days that are still not using this. The most simple way to put it is really a computer or several computers within a computer. You have your bare metal in the box here and then your VMs that sit on top of it. We can also define Virtual Machines as an emulation of a computer system, so you have a host operating system that shares resources of a host computer, and each VM has its own underlying operating system. But it doesn’t need to be the same as the host. For instance, you could be running a windows machine and let’s say you need to test something in Linux. You can have a VM sits on top of that windows host that runs Linux. The VM thinks the hardware is “real” but it is actually just virtual. It also requires a hypervisor or some VM monitor to sit in between the VM and the host to help manage what is going on.

What are Containers?

So VMs are just computers within computers, what is a container? Like VMs they also sit on top of a host, but instead of having their own copy of the OS, they share the kernel as well as binaries and libraries. This sharing is also immutable or read-only as well to make sure that the containers themselves don’t change anything in the host. This also helps reduce the need to reproduce a lot of the OS code and makes the containers lighters. The containers also have everything baked in that the running application will need, like all the code and runtime libraries as well as any system tools that will be needed to function.

Benefits of Virtual Machines and Containers

So now we have 2 ways to run a system. How do we choose the best one?

Benefits of Virtual Machines:

  • All OS resources are available
    You have the entire OS resources at your disposal.
  • Established toolset to manage VMs
    VMs have been running production environments for close to 20 years. This means they are well established in their toolchains and practices.
  • Established security tools & established and known security controls
    They have security figured out, all the tools are in place and the controls are defined and standardized.
  • Fine-grain personalization of image
    You have a very fine grain personalization of the image. Anything you could do to a normal host OS, you could change in a VM. This lets you get everything in order the way you want it.
  • Backup of entire image includes file system
    Since it is a computer within a computer, that makes creating a snapshot or a backup of that running system very easy.
  • Allows running of multiple OS & allows for full isolation
    You can fully isolate and running VM. Each VM doesn’t even know if and what other VMs are doing.

Benefits of Containers:

  • Reduced IT management resources & reduced size of versions
    Containers have lots of shared components which makes the management of these very easy and also reduces the size of versions.
  • Reduced and simplified security updates
    This reduction affects security updates as well, making them easier to manage.
  • Less code to transfer, migrate, and upload
    Less code means less to transfer and move when you want to deploy them to other places.
  • Containers are exceptionally light
    Talking measures them in Megabytes as opposed to Gigabytes.
  • Containers can start in orders of magnitude faster than VMs
    They can also start much faster. Talking MS or S vs min.
  • Many COTS applications are already packaged containers for using best practices
    Commercial off the shelf is starting to package more and more into containers giving us greater flexibility.

What is the Difference?

When to use Virtual Machines?

  • If you have an application that requires all of the OS’s resource
  • If you have multiple applications that need to work very closely together (coupled) and should NOT be deployed separately
  • Applications (think Monoliths) that require a large amount of resources and cannot be broken up
  • When you need full isolation of an application
  • When an application requires a specific OS
  • If there is no container support and you require that from the vendor

When to use Containers?

  • If you need to maximize your server density.
    • Thus reducing the overall cost
  • When you need to be able to scale your application quickly and seamlessly
  • If you need to move your workloads around
  • If you can break your application into smaller components (think microservices)

Check out the video of our CTO, Tim Delesio explains further about Containers vs Virtual Machines: