DEV Community

Cover image for What **is** Docker? 🤷🏼‍♀️
JavaScript➕Coffee🚀
JavaScript➕Coffee🚀

Posted on • Edited on

What **is** Docker? 🤷🏼‍♀️

Terms:
OS: Operating System
VM: Virtual Machine
Server: Big ol’ hunk of metal with some wiry bits
Orchestrator: Something that runs on a website and manages what everything does
Messaging system: Not MSN… in a website, the messaging service essentially runs back and forth between different components and pieces of your site and takes messages from one thing to the other.
Host OS: The base operating system for your machine
Guest OS: Created by a VM

I’m going to set a scene here that we are going to keep referring back to.
You’ve built a website for a big idea. It’s got a form that a user can submit, and it’s got a bunch of other snazzy features. You are very pleased with this and want to take the idea further. You need some help from Randall the developer. Randall is a cool guy. He loves burritos 🌯
To build your website, you are running 3 different OSs, as your essential apps and features run on different operating systems.

Essential app A: Linux version 6.6
Essential app B: Windows
Essential app C: Linux version 5.1

Before we jump straight into Docker, I think it’s important to have some historical context.
Before Docker, and before containers, data was stored and accessed on servers, which are stored in giant fridges called data centres. Every one of these servers holds 1 OS, and they are pretty expensive.

A cabinet holding servers. Wires are plugged in
Back to you and Randall. On top of paying Randall for his excellent skills, you’re paying top dollar for three servers! That’s 3 big hunks of metal, and 3 payments to store them in a data center! That’s going to add up $$$…

This is why hypervisors were invented.

Hyper...what?

Hypervisors are essentially used to split up the memory and storage on a server. This means that you can have one server for multpile OS systems. Oooooooohhhhhhhhh. Exciting stuff.
Let me explain:

Imagine for a second that your server has turned into a big rectangular pizza.

Stay with me, stop thinking about pizza…
A round pizza on a table, cut into portions

‘You have 3 very fussy people coming over for dinner. You need to feed them all. They all eat different things, and don’t like anything else. You also need to eat - so what will you do? It’ll be very expensive to make 4 different pizzas...
You are going to make one huge pizza, but with 4 different flavours in each corner. You decide on the topping, and the amount of toppings, and then bake it in the oven.’

Now I’ll say that analogy again but with some different words

‘You have 3 important applications that run in your website. They all require an OS. They all run on a different OS, they can’t run on anything else. Remember your 3 servers? It’s very expensive to run and keep them all. Your website is also running through something - called Node.js. This is a little more flexible and can run through most OSs.
You are going to have one server, but with 4 different OS running on it. You can also decide on the distribution of resources such as CPU, RAM, and all sorts.’

This is basically what a hypervisor does - you can split your resource (your server) to run multiple OS and assign it as much memory and power as you need (limited to the capacity of your server.) - this way you can run all of your applications (feed all of your fussy guests) on one server, rather than having multiple servers!

A hypervisor also sits under your VMs and provides the base for them. You may have heard of VMs before. Say you and Randall are running your website on your Linux machine, but you really need an application in your site that runs only on Windows. Uh oh. But it’s ok because VMs exist! You can spin up a Windows machine inside your Linux machine….. Confusing. But that is what hypervisors and other VMs do.
The most popular type of hypervisor is VMware, specifically ESXi.

Great, but does that explain Docker?

No.
Docker is actually more like a single server with a hypervisor on top...

The big difference is that a VM virtualises the hardware - this causes the OS to believe that it in fact does have the correct hardware (kernel) to do what it needs to do. In essence, the VM is ‘fooling’ the OS.
Docker, on the other hand, sees what you want to run, and then provides an interface for the programs inside it (that all run on different versions and are a nightmare). It puts them into little virtual boxes, or containers. It is similar to how a VM would do it, but it is it’s own little box, rather than a virtualisation of hardware, and the creation of a ‘guest OS’ (tricking the host OS into thinking it has the ability to run) And it will perform better doing this due to the fact that it uses the base OS kernel, rather than creating something on top of it as a VM does.

Kernel…?

The kernel is a computer program at the core of your computer's OS with complete control over everything in the system. Every OS has one. Your Windows computer has a Windows kernel, your Ubuntu system has a Linux kernel and so on.

You can read more about the kernel in this article

So why is Docker so popular?

Why is the industry going mad for docker right now?

  1. Faster onboarding

This point is pretty self explanatory.
Let's go back to you and Randall.
We already know that you have a Linux machine and you have built your site with Node. So Randall needs to install and get Node up and running. You also have a form on the site, and behind that is a database. So Randall needs to install and get familiar with MongoDB, which you have used. Randall also needs to download, install and get familiar with the site orchestrator and the messaging system

That’s quite a lot to do, and you haven’t even started with Randall on your vision for this work…


Let’s pull this scenario over to a universe where you are using Docker.

Here’s that same scenario:

Randall needs to install and get familiar with Docker.

That’s...it.
You can get on with explaining your vision for your website.

Children pointing at a laptop screen and celebrating

  1. It’s portable

This may sound strange, as it may feel like everything on the internet is portable - that is, you can access stuff on pretty much any machine…

You know that joke of developers saying to testers ‘well, it works on my machine!’?
If they aren’t using docker, then it might be true! We already learned from Randall that some things on your website require different OSs, and have different dependencies (above the kernel level) to run… so if a developer builds a lovely shiny thing and doesn’t build it through docker, then they are relying on everyone that they send it to having the necessary stuff in order to run it!
Docker just wraps all of the code up in OS boxes, or containers, and runs them everywhere and anywhere! This also means that the code can be built by Docker anywhere, allowing for more fluid collaboration between teams.
You must be careful though - if you and Randall build something that references something external, Docker won’t be able to put that into a container - so it may not work as expected on another machine that doesn’t have the external thing

  1. It’s fast....

So it isn’t technically true that Docker is faster than VMs, but it performs better due to the fact that Docker shares the host kernel - it is more efficient and therefore your computer will run smoother - I suppose this gives the impression that it is faster.

It is not wrong to say that it is faster - technically it is - but I’ll leave it up to you if you want to start a fight with someone about it! Ok so it is faster, but it is faster because of the better performance, not because it is inherently just faster.Inside the container (where your website and its contents are happily running), it performs about the same as a VM, but the act of actually having a VM running on your machine is quite performance draining.

To sum up - Docker is essentially a speedy burrito, full of code.
🌯
2 burritos on a square white plate

Thank you to:

Many YouTube videos, particularly
Network Chuck - https://www.youtube.com/watch?v=eGz9DS-aIeY
Many folks on Twitter, particularly:
@mesetatron - for your incredible subject knowledge and clarity of points
☕️Coffee - a staple of my diet
🍵Tea - so many cups of tea
🍦Ice cream - 1 tub of ice cream was consumed!

Top comments (35)

Collapse
 
svenaelterman profile image
Sven Aelterman • Edited

Nice way of making Docker approachable. There are two minor corrections I would like to suggest:
VMware's hypervisor is ESXi, not ESX1. Also, kernel refers to the core of the OS, not to hardware.
On a more important note, you left your scenario dangling without resolution at the end of your story, especially the fact that you're referring to a Linux box. Docker, however, cannot run Windows containers on Linux. The intricacies are covered in this StackOverflow Q&A: stackoverflow.com/questions/421585...

Collapse
 
javascriptcoff1 profile image
JavaScript➕Coffee🚀

Thank you for picking that up! I'm very much a newbie to this myself, so I will read up on what you have said, thank you!

Collapse
 
scmanuel profile image
Manuel SC • Edited

Hi! Congratulations, good article with funny analogies. Just a comment, when you say "You can read more about the kernel in this article" I guess what it follows is a link to another article, but that is missing. Can you provide the link? Thanks!

Collapse
 
javascriptcoff1 profile image
JavaScript➕Coffee🚀

Argh, yes! Good spot, I'll sort that

Collapse
 
_garybell profile image
Gary Bell

MSN?! The nostalgia is strong here! I'm interested in understanding docker more, so I'll read fully after sleep

Collapse
 
javascriptcoff1 profile image
JavaScript➕Coffee🚀

Haha it was the first thing I thought when I learned about messengers!

Collapse
 
devwhoruns profile image
devwhoruns

Good article for starters. For those on .NET Frameworks better shift to .NET core. As for MS, I think soon you can see a future version of windows which will not additional Linux distros probably or better have a linux kernel bundled with its OS. MS is really going good on Open source Tech.

Collapse
 
sunitk profile image
Sunit Katkar

Very good article. Thanks

Collapse
 
dpkahuja profile image
Deepak Ahuja 👨‍💻

Great Article! As a continuation i recommend reading "A docker free intro to containers"
I explain how to create your own containers and images.

dev.to/dpkahuja/a-docker-free-intr...

Collapse
 
cybermischa profile image
Mischa Spiegelmock • Edited

I recently made an intro video discussing containers, docker, and kubernetes. Hope it helps someone.
youtube.com/watch?v=3f5wWYLWOtQ

Collapse
 
phlash profile image
Phil Ashby

Delightful analogies, thank you :)

If anyone is interested in some pictures of what fits inside what, from a data centre / hosting provider view down to containers, I did these as a reference for our team(s) in GBG (hence the specific application names), there was a talk alongside so they are a bit terse but readable I hope: ashbysoft.com/hosting-to-container...

Collapse
 
thesanjeevsharma profile image
Sanjeev Sharma

That was a really good article. Thank you for sharing!

Collapse
 
javascriptcoff1 profile image
JavaScript➕Coffee🚀

I'm glad you enjoyed it!

Collapse
 
affaau profile image
A. Au

Good try. A nice article for me to grab basic idea of Docker.