Docker Introduction

Docker Introduction

ยท

5 min read

Welcome to my first article in this beginner friendly Docker Series. I've got my hands on docker lately and decided to start this series to document my learnings in an easy and understandable way. Let's get Started!

Introduction

Whenever a product is designed, the first and foremost goal is to solve a particular problem or somehow to reduce the friction that users are currently facing with a particular problem.

So, In order to understand Docker, first we need to understand the problem statement that Docker is trying to resolve!

Docker Problem Statement?

Whenever a developer develops a product, there will be certain issues that occurs almost every time.

Well, that problem is when ever we develop a project it works absolutely fine in our machine but as soon as it moved to other machines/servers/production, the project fails to work with the same performance due to dependency issues caused by moving the project from one place to another place.

To give you a basic example, whenever we develop a website using PHP or may be using asp.net and moving that project to web servers, there are definitely some uncertainties like your images are not loading or may be the path is little glitchy.

So the classic problem is something like....

It is working on my machine.gif

Docker is specially designed to resolve this problem "it works on my machine!"

Some Key Features of Docker

  • Docker is compatible with almost any programming language.
  • Docker allows you to have containers which are like heart of docker. These containers wrap up your code and they are absolutely portable.

So, Docker is a software that allows you to create containers which are portable and packed up with your code, dependencies, configurations, processes you are running and networking information. In some of the special cases, it also consists of the chunks of some of the operating system that is responsible for tweaking out somethings in your code.

In order to summarize, Docker can be used as three main essential things

  • It is a client side application, we can just Install it and it can do all the things for you including designing a container with all of our code and dependencies.
  • Docker can also act as a service and can be deployed to server. so that you can take the container and can be deploy it to anyplace.
  • We can also publish the docker images, so that whenever somebody wants to start at a given specific checkpoint, they can start there using that docker image.

What is Container?

Let's discuss about the container using an example, In the below example at hardware level we have installed node with version 7.4.

In regular, when we install node in our machine, the latest version will get installed, but in the real world production level this doesn't happen. Even upgrading to a minor change will count here, Every single version with what type of support they are providing is very important here.

Considering the below application is at production level, if we install node with version 7.4 in our system, but this application might not work for node versions 7.6 and 7.9.

So how can we run this application on other versions?

image.png

In our hard disk, there are some segments that we can make, we can copy of version 7.4 and we can upgrade or install a fresh version. this process is known as segmentation/namespace. A separate disk space for installing specific version of the software.

Segmentation: Segmentation is a memory management technique in which the memory is divided into the variable size parts. Each part is known as a segment which can be allocated to a process

Similarly, we can create multiple copies of the software. when we containerize the entire application for node version 7.4, it includes the following

  • some of the system calls
  • some part of kernel
  • some chunk of OS (Windows/Mac/Linux)
  • some part of hardware specifications so that where ever you deploy this, it will consume same type of segmentation there.

Container.png

So, if we put this container in any other machine, it will work with the same specifications.

But it looks almost like a virtual machine, what's the difference?๐Ÿค”

Docker vs Virtual Machine

In the case of virtual machines, a layer of hypervisor is installed on these machines that allows multiple VMs to run on a single machine. On top of this hypervisor we will get a couple of containers in which we install a guest operating system. we can have some application being loaded with some configurations.

what's the difference?

image.png

  • Each VM includes a full copy of an operating system, the application, necessary binaries and libraries โ€“ taking up tens of GBs
  • These guest operating systems running couple of instances of entire operating system is resource consuming.
  • Having an entire operating system is tricky when especially we are not using all the components in that guest OS. it is like almost the wastage of resources.

image.png

Docker comes up with containers without using the resources as much as used in virtualization.

  • Containers are an abstraction at the app layer that packages code and dependencies together.
  • Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space.
  • Containers take up less space than VMs (container images are typically tens of MBs in size)
  • Containers can handle more applications and require fewer VMs and Operating systems.

Conclusion

Thanks for reading! I hope you find this article helpful in understanding the importance of docker, containers and difference between docker and virtual machine. Stay tuned for the next part of this series where I will Installation of Docker and creating a container. Cheers!

Did you find this article valuable?

Support Jayakiran Guntuku by becoming a sponsor. Any amount is appreciated!