Docker Series: Unveiling the Mystery, Containers vs Virtual Machines

Hello readers, my name is Rishi Vamshi Athinarap (LinkedIn) and I am currently pursuing my master's in computer science at UNC Charlotte. In this series of blogs, I am sharing my journey of learning and understanding Docker. This blog, 'Docker Series: Unveiling the Mystery, Containers vs Virtual Machines' is a part of my 'Learning in Public' initiative where I document my learnings and understanding in the form of public notes. Join me as I dive deeper into the world of Docker and explore the differences and similarities between containers and virtual machines. Let's begin the battle of the Titans!

So what is the technical definition of a Container?

A container is a lightweight, stand-alone, executable package that includes everything needed to run a piece of software, including the code, a runtime, system tools, libraries and settings. Containers provide a way to package and distribute software in a consistent and portable way, allowing it to run consistently across different environments such as development, testing and production. They are isolated from one another and the host system, so it is possible to run multiple containers on a single host without conflicts.

And what is a VM?

A virtual machine (VM) is a software implementation of a computer that executes programs like a physical machine. It provides a virtualized environment for the operating system and applications to run on, allowing multiple operating systems to run on the same physical hardware. Each virtual machine has its own set of virtualized hardware, such as CPU, memory, storage and network interfaces, and runs as an independent and isolated system. This allows for multiple isolated environments to run on a single physical machine, improving resource utilization and enabling flexibility in managing and deploying software.

Let's put the technical jargon on hold and break it down in layman's terms, shall we?

I got this analogy from the depths of the internet, specifically from a subreddit where clever comparisons and witty references are the norms. So, a big shoutout to the wise folks on that subreddit for helping me explain the concept of containers and virtual machines in a way that even a five-year-old could understand! Source

Containers are like building a fence around your application (the dog) so that the dog doesn't mess up your whole house (the OS). It keeps the application isolated and confined to a specific area, while still allowing it to share the underlying operating system resources.

Virtual machines, on the other hand, are like building a whole new house for your dog to live in. The dog can do whatever it wants in its own house, it has its own operating system, and it can't affect the host operating system or other virtual machines. The dog has full autonomy over its own "house" and resources but takes up more space, just like how virtual machines take up more resources.

Let's dive into Differences -

The key difference between containers and virtual machines is that containers share the host kernel and do not require a hypervisor, while virtual machines run on top of a hypervisor and require a separate operating system for each instance. Containers are more lightweight and efficient as they share the host kernel, while virtual machines require more resources as they run a separate operating system.

ContainersVirtual Machines
Share the host kernelRun on top of a hypervisor
More lightweight and efficientRequire more resources
Allow for consistent packaging and deployment of applicationsAllow multiple operating systems to run on a single machine
Provide isolation at the process levelProvide isolation at the hardware level
Can run on any infrastructureRequire a hypervisor to run
Fast bootupSlow bootup

In conclusion, containers and virtual machines both have their own unique benefits and use cases, but containers offer a more lightweight and efficient solution for application deployment. And speaking of containers, we can't end this blog without mentioning Docker.

So what exactly is Docker?

Docker is a platform that allows developers to easily deploy, run, and manage applications in containers. Containers are isolated environments that allow for consistent and reproducible software environments, regardless of the host system. Docker enables developers to package an application and its dependencies together in a single container, making it easy to move the container between different environments such as development, testing, and production. This helps to improve the portability, efficiency, and consistency of application development and deployment.

This blog is an introduction to Docker and stay tuned as we dive deeper into the world of Docker and explore its capabilities and best practices in future blogs.

End Credits:

A special thank you to my dear friend, Srikar, a current CS grad at Santa Clara University and an ex-SDE 2 at Amex ( LinkedIn ).

0
Subscribe to my newsletter

Read articles from Rishi Vamshi Athinarap directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rishi Vamshi Athinarap
Rishi Vamshi Athinarap