VM vs Docker — Learn Devops Concepts like I am Five

Shikhar Srivastava
4 min readFeb 21, 2021

One fine day an earnest boy named Russel, a newbie in the DevOps world came to our elderly experienced guy in this domain Carl Fredricksen.

Similar to other days of the week, Carl is in the mood to ignore him but Russ following his curious nature, came with excitement to learn all he can.

Russel: Hi Carl, I am here and ready to explore the DevOps world !!

Carl: Don't get too excited, I am quite busy. Let's meet someday else.

Russel: No, let's do it today. I have done some homework too on the topic.

Carl: Okay! We can continue if you will ask the right questions.

Russ: Ya I will, as always 😛

Carl: Okay let's start the journey

Russ: I am currently using VM but I heard Docker is much faster to download. Is Docker a lighter VM?

Carl: Let me tell you a short story by comparing this scenario with House and Apartment

In a house, you have the full infrastructure, pipeline system, electricity connection, few bedrooms, living room, washrooms, etc. It's fully isolated and used by an individual.

So all the cost needs to bear by an individual as its isolated infrastructure.

So suppose you wanted a place to just sleep and poop. The whole house will not be a convenient and reasonable option.

So let's see our other option ‘Apartment’.

The apartment is like shared infrastructure. The common things pipeline system, electricity infrastructure, lift, etc are shared. So in a similar case, if I want a place to sleep and poop, I don’t need to pay as an individual for all infra cost of building which will be shared among all society members. What cost me is the Apartment rent.

So here you can see Houses(VM) are fully self-contained while Apartments(Docker) is a shared infrastructure with benefits of their own.

Russ: Wow what a nice explanation. Can you explain more technically now?

Carl: Glad you asked.

Virtual Machines is made of layers

  1. Infrastructure: This could your laptop or dedicated server on a cloud-like EC2 instance
  2. Host Operating System: Any standard OS like Linux, Windows, Mac, etc
  3. Hypervisor: It is software that creates and runs virtual machines (VMs). Eg are VMWare/Virtual Box, Hyper-V, etc
  4. Guest OS: This gets installed on top of Hypervisor. In case you have multiple isolated applications, multiple Guest OS gets installed which can be anything like Linux, Windows, etc.
  5. Application, Binaries, and Libraries (Sorce Code): This gets installed on top of Guest OS.

You see here, Guest OS needs to be installed for each app which is pretty heavy and consumes a lot of memory and space.

Russ: Ya, it seems if can remove GuestOS is would have saved a lot of money.

Carl: Hahaha, yes you on right track but a little late to innovate. Docker has done the same for you.

Instead of Hypervisor, we have Docker Daemon here. This Docker Daemon is a service that runs in the background, interacts with the underlying OS, and manages everything inside Docker containers. We will discuss more regarding Docker Daemon later. Hold your thoughts.

After Docker Daemon we directly have Application Binaries and Source code. You see we have removed heavy Guest OS dependency.

Russ: Ohh That’s why it is faster to start than VM. And of course, it is not a lighter VM but a whole new concept. (Russ Feeling dumb)

Carl: Yes and in turn saves lots of time and space. The application gets build in a special box called Docker images and isolates from other containers and OS.

Russ: So does it mean we should switch everything from VMs to Docker as this seems to be best.

Carl: That’s a young generation problem who gets to the conclusion so fast.

Russ: 😔

Carl: Docker Isolates applications but doesn’t Isolate the whole system which can be a requirement in few cases. We can discuss that some other day soon.

Russ: Great I understood it now clearly !!

I have one more question on this, my app is having many modules which interact with each other using Webservices. Apart from that, it has few external dependencies too. I am struggling to ship them from one environment to another as I always need to provide instructions on how to set up all these, pretty frustating. Some help, please.

Carl: One concept a day, please. I can give you a hint though, Docker Containers can solve all your problems. But How? This is homework for you. Try to do it yourself or wait for the next day to ask. 😄

Russ: Ayee Sir!!

--

--

Shikhar Srivastava

SRE / DevOps Engineer with rich experience in multiple renowned firms. I am here to give back to the community by sharing knowledge!!