What **is** Docker? 🤷🏼‍♀️
Tags: docker, codenewbie, beginners
Published: 2020-09-20 16:18:05

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](https://cdn.pixabay.com/photo/2018/01/22/21/34/sever-3100049_1280.jpg)
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](https://cdn.pixabay.com/photo/2017/12/09/08/18/pizza-3007395_1280.jpg)

‘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](https://afteracademy.com/blog/what-is-kernel-in-operating-system-and-what-are-the-various-types-of-kernel)



### 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](https://cdn.pixabay.com/photo/2015/01/08/18/24/children-593313_1280.jpg)


2. 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**

3. 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](https://cdn.pixabay.com/photo/2019/04/14/03/08/burrito-4126108_1280.jpg)

##### 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!