# Docker Overview

Why we need Docker ??

![](/files/-MEQtIHwZEhyfaAzLI1b)

\>Lets say we have a requirement to setup end-to-end application stack including various different technologies like a Webserver using NodeJS , and a database such as MongoDB , a messaing system like REDIS & a orchestration tool like Ansible. We will have lot of issues developing this application stack with all this different components.

\>First the their compataibilty with underlying OS is the issue. We have to ensure that all these different services needs to compatible with the version of OS we are planning to use.

\>Secondly we have to check the compatibilty between the services & the libraries & dependencies on the OS . We will have issues that one service require a one version of dependent library whereas another service requires another version . The architecture of our application change over the time. We have to upgrade to newer version of these componenets or change the database etc . Every time something changed , we had to go through the same process of checking compatilbilty between these various components & the underlying infrastructure. This compatibility matrix issue is usually referred to as "Mtarix of Hell'.

\>>Next, every time we have a new developer onboard , we found it really difficult to setup a new environment . The new developers have to follow a large set of instructions running hundred of commands to finally setup their environments . They had to make sure that they were using the right operating system , the right version of each of these components and each developer have to set all that up by himself .

\>> We also have different Dev/Test/Prod environments . One developer comfortable with one OS , the others maybe comfortable using another one. So we couldn't guarantee that the application that we were building will run the same way in different environments. So all of this made our life in developing , building & shipping the application really difficult . So i need something that could help us to the compatibility issues & something that will allows us to modify or chnage these components without affecting the other components & even modified the underlying OS's as required & that  search landed us on Docker .

> With Docker we can use these components in separate container with its own dependencies & its own libraries all on the same VM & the OS withini separate environments & containers which have to build DOCKER configuration once & all our developers could now get started with a simple Docker run command irrespecctive of what the underlying operating system they are running on . All they needed to do to make sure that they have DOCKER installed on their systems .

![](/files/-MEQtEuY7mtvNm1E0tVk)

What are containers ?

Containers are completely isolated environment as in they can have their own Processes, Network interfaces & their own mounts just like virtual machines except they all share same OS Kernel.

Different types of containers we have :

a) LXD  b) OpenVZ  c) Rkt (Rocket Containers)

Docker utilizes LXD containers .

![](/files/-MEQcCtSNo_f8ITDAVF3)

Lets try to understand first operating systems : Operating Systems like Ubuntu, Fedora, SUSE , Centos . They all consist of two things : an OS kernel & a set of softwares. The OS Kernel is responsible for the underlying hardware while the OS Kernel remains the same which is Linux in this case. Now its the software above that makes this operating systems different .

This software may consist of a different user interface , Drivers, Compilers, File Managers, Developer tools etc. So we have a common Linux Kernel shared across all OS's & some custom softwares that differentiate operating system with each other.

Docker container shares the underline Kernel shown below.

Each Docker container only has the additional software that makes this operating system different & Docker utilizes the underline Kernel of the Docker HOST which works with all OS's above.

\>>Now we won't able to run a Window based container on a Docker HOST with Linux on it . For that we require Docker on Window server.

\>>Now when we install Docker on Windows & run a Linux container on Windows , we are not running a Linux container on Windows. Windows runs a Linux container on a Linux virtual machine under the hoods. So its actually a Linux container on Linux virtual machine on Windows .

So isn't a disadvantage that we not able to run another kernel on the OS . Answer is NO bcoz unlike HyperVisor Docker is not meant to virtualize the different Operating systems on Kernels on the same hardware .

\>>The main purpose of Docker is to package & containerize applications & to ship them & to run them anywhere anytime as many times as we want . Now that brings us the differences between Virtual Machine & Containers.&#x20;

![](/files/-MEQcv9Ly7MpNTjO2vAx)

Differences between Virtual Machine & Containers.&#x20;

![](/files/-MEQgT5HlIPPIncbycwr)

1\) As we can see on the right, in case of Dockers we have the underlying hardware infrastructure then the OS & then the docker installed on OS. Docker then manages the containers that run with libraries & dependencies alone.

2\) Now in case of virtual machines , we have the Hypervisor on the hardware & then the virtual machines on them . As we can see each virtual machines has its own OS inside it then the dependencies & then the application. The overhead causes higher utilization of underlying resources as there are multiple operating systems & Kernels running . The VMs also consume higher Disk Space as each VM is heavy & its usually in GBs in size. whereas Docker containers are light weight & usually in MBs in size. This allow Docker containers to boot up faster usually in a matter of seconds whereas VMs as we know minutes to boot up as it needs to boot up the entire operating system.

3\) Also important to note that Docker has less isolation as more resources are shared between the conainers like Kernel whereas VMs as complete isolation for each other since VMs don't rely on the underlying OS Kernel.&#x20;

4\) So when we have large environment thousand of application containers running on thousand of Docker HOST . We will often see containers provisioned on Virtual Docker HOSTS that way we can utilize the advantages of both technology . We cab utilize the benefits of virtualization to easily provision or decommision Docker HOST as required & at the same time we can utilize benefits of Docker easily provisioned application & quicly scale them as rwquired.

There are lot of containerized versions of applications readily available as of today . So most organizations have their products containerized & available in a public Docker  repository called Docker HUB or Docker Store.For example : we can find images of common OS's , databases & other services & tools .Once we identify the images we need , we need install docker on my HOST bringing up an application is as easy as with a Docker run command with name of the image.

\>If we need to run multiple instances of the webservice simply add as may instances as we need & configure a LOAD balancer or some kind in the front . In case one of the instaces fail simply destroy that instace & launch a new one.

![](/files/-MEQkspW9-fqxPTgpYyJ)

Container Vs Image:

\>An image is a package or a template just like a VM template that we might worked in the virtualization world . It is used to create once or more containers .

\>Containers are running instances of images . They are isolated & have their own environment & set of processes .&#x20;

\>>As we have seen a lot of products have been dockerized already .In case we cannot find images we are looking for we can create our own image & push it to Docker HUB repostiry making it available for public .

> A Dockerfile is used to create image of an application. This image can run on any HOST with Docker installed over it.

![](/files/-MEQmYXeaWySmsJvukWG)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://architectures.gitbook.io/project/docker/introduction/docker-overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
