Containers vs VMs
Chronicles of Containers - Part 1
After a short break due to one too many speaking engagements, kicking off the new BitesizedEngineering series that will fully focus on Containers, how they work under the hood and how it all works natively on Windows (yes, I said it multiple times so far but I still keep seeing the same question pop-up - it's possible and it works natively on Windows).
For starters, I want to clear up all the confusion. Containers are NOT similar to VMs. They do aim at achieving the similar goal (virtualizing stuff), but the underlying tech is completely different.
Think of Virtual Machines as literally taking a full Operating System code (e.g. Windows, Linux, OSX, etc.) along with the programs that you want to have installed, and placing all of that into an archive (e.g. a ZIP archive). Next, using a Hypervisor (a program that knows how to unpack those ZIP), you unpack that ZIP file and execute it. If your underlying machine supports it, the hypervisor can run the packaged OS directly on underlying Hardward, so you achieve the same performance as if you just installed the OS directly on your storage medium (e.g. SSD or HDD).
Benefits of VMs are great - you get a 1:1 replica of your entire operating system and you can deploy it anywhere you want (e.g. on another machine, on Azure, etc.). It's great! But it's also bulky as hell; doubly so if all you need is to pack your executable with its dependencies! And that's where we land on Containers.
Containers are pretty much the opposite thing - they are dull and slim and they require an OS to run them. But what they give you in return is the ability to simply pack ONLY WHAT YOU NEED (e.g. your EXE + it's dependencies) whereas everything else is provided by the Host's OS system. The result? You get a slim version of your executable, runnable anywhere, while still benefitting on all the isolation, distribution and other benefits you chose to virtualize your stuff for in the first place.
Now, if you are one of the more savvy users, you'd probably say - WELL, WAIT A MINUTE, YOU, ... You claim they package only what we need and yet most of the containers we are seeing are built from images that package some version of OS. And you'd be right! I lied a tiny bit to make my point :) But it's for a good cause! Those OS' that you see are super-slimmed and trimmed-down versions (for Windows it's Nano version, and for Linux I believe it's "slim-linux"), but they still rely on underlying OS to do all the execution. So technically, I didn't lie, right? I just omitted a small piece of info which will require future articles to transfer the point accross :) And that's exactly what future graphics will be about - opening up and looking deeper under the hood!
Other articles in the Container series:
Docker != Containers (Part 2 of the series) - deals with the common misconception that “Docker” is all there is in Container world.
Container is not a VM - and what that really means? (Part 3 of the series) - a glimpse into some of the main differences between the two.
Containers are like The Truman Show (Part 4 of the series) - some words on the fact how Containers see themselves (and what really happens on the outside).
Thanks for reading Bitesized Engineering! Subscribe for free to receive new posts and support my work.