Let's Learn Docker

Let's Learn Docker

Before Docker

First, let's look into the background picture before docker came into existence. So, there are many companies running their own applications on servers. In the beginning, if we want to run multiple applications we use to need multiple servers. One server is able to run only one application. When companies want to scale their business across many people and the count of applications goes up the servers used to go down because servers are not able to handle more applications. So, companies used to buy more serves as the application traffic grows up. Buying a new server every time for a new application is not a cool idea right and it is not cost-efficient.

Here comes the protagonist who solved this distressing problem. "VMware" is a company that solved this problem by introducing Virtual Machines. This helped companies to run multiple applications on a single server. Virtual machines need a dedicated OS(operating system) which in turn leads to dedicated storage, CPU allocation, ram, and all those types of things. Virtual Machines solved the problem of having multiple applications but it's not that efficient because they should have a dedicated os. Let's assume you are running 5 to 10 different applications on your computer. Now they all take dedicated OS, CPU & ram to run. So, the computer becomes slow and it will be frustrating to work on a slow computer. The other problem is if you shared your work with your friend and he tries to run your application on his device and the application doesn't run. The friend wondered why it is not working on my computer. It doesn't work because even though you have done all the steps right in running the application the dependencies, the packages, and the version with which he has built are not matching with your versions on your device. So, to run the application you should install all the dependencies, packages, and versions which your friend built.

Uffff!!! very tedious process right? Yes, so to solve this problem and to run the applications on a single OS unlike the virtual machines they introduced "Containers".

Containers

The basic definition of the container is " It is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another".

Docker-Windows-Containers.jpg

Let's understand the definition with an example: You are in India and you want to send some stuff to your sister who is doing MS in America. Suppose there are 10 items and if you want to send them you will pack all of them in one box and parcel the box right. You won't parcel each one separately and send it right. So, here the box is a container. If you are sending your application to your friend this time you will send it by a container. In this container, you will include all the dependencies, packages, versions, backend, frontend all the things you used to build and run the application. So, this time when your friend wants to run your application on his device he will install the version and data you sent in the container. So, that he will not face any problems running your application on his device. Very fast right? Yes, it is very quick and very easy.

containers-vs-virtual-machines.jpg

Hypervisor: It is also known as a virtual machine monitor or VMM. It helps in creating multiple machines on the host OS and managing these machines.

You can see in the above picture, containers have only one OS, and VMs have multiple OS. So, here you may have doubt that in VMs we have a hypervisor to create and manage the OS. But how you will run multiple applications in containers? Using Container Engine.

Docker

Book definition: Docker is an open-source containerization platform. It enables developers to package applications into containers—standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment. In simple words, we can say that it is an application build and deployment tool.

In simple words, Docker is a tool to create and manage containers that are just isolated movable environments having your code. The other name of the docker is Container Engine.

Docker-build.webp

Now we all know what is docker. Let's now discuss the components inside the docker.

Docker Runtime

Docker runtime allows us to start and stop the containers. It has two levels one is "runc". It is a low-level component mainly focused on stopping and starting the container. The other one is "contained". It is a high-level component. It actually manages runs and does high-level work like pulling images, connecting with the network ...etc.

Docker Engine

The docker engine is the core part of the docker. It helps us in interacting with it.

njj.jpg

Docker Client

This is what you use to interact with Docker. So, when you want to do something you will send a command to the daemon by using CLI(Command line Input).

Docker Daemon

Its whole purpose is to perform the commands that the client issues. It listens to the API requests being made through the Docker client. It creates and manages your Docker images. We can say that it is the brain of the docker.

Docker uses a client-server architecture. Here the client is docker CLI and the server is Daemon.

Docker File

Docker images are the read-only binary templates used to create a docker container. Single file with all dependencies and configurations required to run a program.

Docker Container

container holds the entire package that is needed to run the application. Or in other words, we can say that the image is a template and the container is a copy of that template.

The container is like a VM. Images become containers when they run on the docker engine.

Advantages of docker

  1. Less Cost.

  2. No pre-allocation of RAM.

  3. CI Efficiency- Docker enables you to build a container image and use that same image across every step of the deployment process.

  4. It is lightweight.

  5. It can run on physical hardware/virtual hardware or the cloud.

  6. We can reuse the image.

  7. It takes very less time to create the container.

That's all for now. Please like and share if you found this information informative. If you have any questions, please leave them in the comments section and I will do my best to answer them.

Thank you for reading, and I'll see you next time.