Containers

How are containers different from virtual machines (VMs)?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

The primary difference between containers and VMs is that containers allow you to virtualize multiple workloads on a single operating system while in the case of VMs, the hardware is being virtualized to run multiple machines each with its own guest OS. You can also think about it as containers are for OS-level virtualization while VMs are for hardware virtualization.

  • Containers don't require an entire guest operating system as VMs. Containers share the system's kernel as opposed to VMs. They isolate themselves via the use of kernel's features such as namespaces and cgroups
  • It usually takes a few seconds to set up a container as opposed to VMs which can take minutes or at least more time than containers as there is an entire OS to boot and initialize as opposed to containers which has share of the underlying OS
  • Virtual machines considered to be more secured than containers
  • VMs portability considered to be limited when compared to containers