Containers vs Virtual Machines
The foundation of Kubernetes is, of course, containers, but what’s the difference with virtual machines? A container is a fully isolated process that can run on its own using a host system. This is comparable to running virtual machines on a system or hypervisor.
The difference between a container and a virtual machine is not always easy to distinguish. To make a long story short, a virtual machine virtualizes the entire server using hypervisor technology. Hardware is emulated, and an operating system runs on it that communicates with the virtual hardware. In contrast, a container uses container technology, with Docker being the most well-known. Docker uses a container runtime such as containerd. There’s no emulation like we see with virtual machines; instead, the kernel is shared with the host system.
This results in essentially less overhead, as no resources are lost to hardware virtualization. However, the line between the two is not always clearly drawn, as there are several technologies that sit somewhere between a virtual machine and a container. For example, there's paravirtualization and PCI passthrough, where the virtual machine directly interacts with the host system’s hardware.
The use case for containers and virtual machines is clear, though. A container essentially has no persistent data. If you stop the container, you lose everything running on it unless you're working with specific mounts. You always start from a pre-built container image, which contains all the software needed to run your process. Containers are also much smaller in terms of storage, CPU, and memory. You can easily run about 100 containers on your local system, something nearly impossible with virtual machines.
Read more about this topic in our second part on Kubernetes!



