Understanding Docker and Containerization with Real Life examples
I am pretty much sure that you have been to some video or read a blog about Docker, but got confused with those term “Containers”, “Images” and so on. And now you are here trying to win the fight against Docker, But you are not alone here as i am also Here to help you. So let’s Start the battle
When I was 15 I was fascinated with the term hacking and anything related to it seemed very cool to me, But the first thing that i came to know while exploring it was LINUX (Operating System) but at that point i was scared of terminal and the black window, So i was a bit scared to remove my windows OS and change it with Linux. I got to know about VIRTUAL MACHINE and Virtual Box, which basically will run LINUX on top of my my slow Windows.
So when i will start the Virtual Machine on my desktop, there will be two OS working on the computer at the same time, since my windows OS alone use to work slow on my old PC, after starting the Virtual Machine it will make my cry as it become even more slower.
Because of which i stopped working on hacking within a week and here i am now. So you got my point the main disadvantage of working with VM is it takes much of yours computer hardware to run another OS which makes it Slower. But what is so different about Docker
Docker in simple term is an application just like your normal application running on your OS inside of which i could run a LINUX or even an application.
This is where Docker comes into play
Before Explaining you what exactly is Docker with it’s not so good definition, Let start with something else.
What is a Container ?
Yes, you are right that’s exactly what i meant with a container. Now what if i say you have to life 1 week inside this container. You will be like, Okay but you have to provide me
Food, Water, Internet Connection and few more things. If i provide all the things in this container you will be completely ready to stay in a container for a week.
How is this relevant to my application
Now let’s say you have an application that you want to also live 7 day inside this same container. For obvious reasons your applications (Assuming a NodeJS) will also have few demand like Node, Environment Variable, npm and few more things.
If you provide the all the requirements your application can run an entire decade inside this container without a problem.
This is called Containerization
And since in real life also to manage a place with with so many containers, We need a Place to keep the container and few people to manage it.
In the case of Application this is Managed by Docker inside our computer. Now the question is but why do i even need a container, I can code it directly on my Desktop without the help of any container.
The Most common dialogue you might have heard of is IT WORKS ON MY COMPUTER
Let’s say you made a complex application which you want to show to your friend you copy all the files to your pen drive take it your friends home and let me guess it didn’t work.
The list of problems can be very long. that would have caused that problem. Example Different Node Version. This is what Docker solves
Real Life Example Continues
Remember i put you inside a container for 7 days and i got a idea of transporting you somewhere else it is so easy for me, I will put that container on a truck and take you wherever i want
So can your application since the application has all the things it need inside the container now i can take the container wherever i want and i the truck in application terms is called Docker Hub. With the help of Docker hub you can take your application in any computer and one thing i can guarantee is The application will Work