Docker

Docker Introduction

Docker

So, the thing is that before understanding docker, we need to understand some well-known concepts like virtualization and hypervisors.

For that, let us look the pictorial representation of three and learn layer by layer.

virtualization vs hypervisor vs docker

From the picture above, it must be crystal clear that in case of:

  1. Virtualization: It runs on top of the host Operating System.
  2. Hypervisor: It runs on top of hardware, also known as bare-metal virtualization.
  3. Docker: It also run on the top of host OS but there is a small difference in this.

Question: So, If docker also runs on the top of the host Operating System, how is it different from virtualization?

Answer: In case of virtualization, each machine created whether it is a Windows, or Linux or macOS, or any other operating system, will install its own kernel and hence,

number of virtual machines = number of the kernel running in an isolated environment


Virtualization vs Docker

virtualization vs docker

The picture above shows some key differences between virtualization and docker:

  1. Hardware = It rarely matters, 99% of times no difference at all.
  2. Host OS = Any OS can be used for the both, but because of some reasons, Linux suits best for docker.
  3. Images = It can be seen, that the size of an image is very big in case of virtualization as compared to the other.
  4. Storage = After the start, during running state as well, the size of virtual machines are again big as compared to Docker containers.
  5. Boot Time = Again, the boot time of virtual machines are very large, whereas docker containers runs very fast, in seconds.

Question: Why docker is best suited on Linux?

Answer: The reason behind this is that the docker’s main application/utility utilizes the OS’s kernel for its task/job completion.

Question: What is actual meaning of the answer given above?

Answer: It mean that the containers created under docker application are kernel-less and they use native Host OS’s kernel to perform tasks, that is why containers are efficient, fast, small and portable.

Question: What are some different names of docker?

Answer: They are following:

  1. Container Based Virtualization
  2. OS Level Virtualization
  3. Lightweight Virtualization
  4. Microservices

Virtual Machines vs Docker Containers

Virtual Machines vs Docker Containers

Virtual Machines = Guest OS + Binaries/Libraries + Application’s code

Docker Containers = Binaries/Libraries + Application’s code

There is a small yet big difference between containers and virtual machines and that is the Guest OS layer.

As discussed above, containers use Host OS’s kernel but virtual machines need their own native kernel in order to perform tasks.

Note: Docker containers run as isolated user-space process under Host OS via sharing its kernel.

Note: Docker containers are nothing but applications/code packed with their dependencies.

Question: So, apart from all the above discussed, what is the main purpose behind using docker and its containers?

Answer: An application packed with its dependencies can be transported to test environment, to development environment, to production environment without worrying about any kind of error.

Scenario

Before Docker = An application’s code is written and compiled, when the application is tested and executed on developer’s computer/laptop and it requirements (dependencies are > mysql5 and php6), but when the same compiled code is sent to tester and tried to run “it eventually fails”, from here the problem begins.

Problem = Tester was unable to figure out the root cause of the error, so the developer is told to recheck the code, the code is rechecked and it is again running without errors on developer’s machine, but when resent to tester, the problem persists.

Root Cause = The root cause is nothing but dependency problem, i.e. the version of mysql and php being used on tester’s machine is different from that of developer’s machine, mysql5 + php6 on developer’s machine but on tester’s machine, it is mysql3 + php4.

Comment = It may look like a small problem on this scale, but in real-time production environment it may result is drastic problems.

Solution = Docker Containers, it is the only way to remove such problem, because containers are packed applications with their dependencies.

RECOMMENDED

Comment here