Docker

Docker

Containerize Your Applications by Docker

ยท

5 min read

Hey ๐Ÿ–, this is the blog on the basics of Docker. In this blog, you will learn about various topics about docker like docker container, docker image, docker hub and many more. So if you want to learn about containerization then this blog is for you. Let's start reading the blog.


What is Docker?

Docker is a platform where you can containerize applications. Containerizing an application means packing up all the resources which are necessary to run the application on any machine.

As in the above diagram, if an application has to run the application on any machine successfully then it needs suppose 4 resources front-end, back-end, database and other system requirements. Then we can put all resources in a container to make sure whenever a person uses this application by using this container, the application will run on any machine because it already has the resources in the container to run the application.


What is the need?

Before going to the need for docker let's first understand various ways through which we can run our application on a machine. There are three concepts to running an application on a machine and those are the Traditional concept, Virtualization concept, and Containerization concept.

  • Traditional Concept: In the traditional concept, the host OS run on top of hardware and at the top of the host OS all the apps will run. As given in the diagram.

    Let's take an example to understand its disadvantages. Suppose you created an app that needs certain resources and hardware to run the app and you give the app to your friend to run on their computer. But your friend doesn't have access to the resources and hardware required for the app to run on his computer. So basically your friend can't run the app on his machine. This is bad right? So the traditional concept is not that good.

  • Virtualization Concept: Before starting with the virtualization concept you have to know about certain terms like a hypervisor, virtual machine, and guest OS.

    • Hypervisor: A hypervisor is a software that creates and runs Virtual Machines. A hypervisor can run multiple Virtual Machines on the host OS.

    • Virtual Machine: Virtual machine is a digital version of a physical machine or computer. It can do all the things that a physical machine can do but it doesn't have any physical existence.

    • Guest OS: Guest OS is the operating system that runs on a particular Virtual Machine on top of a host OS.

So in the virtualization concept, the host OS run on top of hardware and top of the host OS there is a hypervisor. And the hypervisor creates and runs different virtual machines. And on the top of each virtual machine, there is a different guest OS to run different applications on each guest OS.

Now let's take the same example to understand its disadvantages compared to the containerization concept. So if you want to give the application to your friend then your friend will create and run a Virtual Machine and use a guest OS to run the app on his computer system. But creating different Virtual machines and using a guest OS in each Virtual Machine on top of a host OS is overweight. This is the disadvantage of using the virtualization concept.

  • Containerization Concept: In the containerization concept, the host OS run on top of hardware and top of the host OS there is a container runtime that creates and runs a container. And inside each container, our apps will run.

    Again let's take the same example to understand its benefit. So if you want to give the application to your friend then first pack up all the required resources to run the application in a container and give the container to your friend so that your friend can run the application on his computer without any interruption since already all the required resources are in the container. That's why it is a lightweight concept since we don't have to use different guest OS on our computer system.


What is Container?

A container is a place where all the resources to run an application are packed up. You can think of a container as a box that contains all the resources to run an application such as front-end, back-end, databases, system resources and everything.

Let's take a good example to understand this concept. Suppose you prepare a dish in your home and you want to send the dish to your friend so that your friend can also taste the dish and can give you some compliments. But the problem is your friend's home is too far and to go to your friend's home takes 20 hours. If you send the dish to your friend then it will get worse. So now what would you do? The solution is to pack all the required ingredients for the dish and the recipe of the dish in one box and send the box to your friend so that your friend can prepare the food and can enjoy it. So here container is the box which contains all the resources for the dish.

What is an Image?

An image is a set of instructions to create a container. We can create an image of any application. So as the name suggests, an image is the photo of the application and by seeing that photo containers are created by the container runtime.

What is Container Runtime?

Container runtime, also called container engine, is software that creates and runs containers on the host OS. A container runtime has several jobs. It loads container images from a repository like Docker Hub, gets information about local system resources, isolates system resources for the container, and manages the container lifecycle.

What is Docker Hub?

Docker Hub is an online registry of docker where all the images of a container are stored. And we can pull an image from the docker hub to create and run a container in our machine.


Thank you for reading the blog. More on docker will be on my upcoming blogs.

Like, Share and Comment. โ™ฅ

ย