Why do we need docker?

Prateek Aryan
2 min readDec 28, 2020

This blog is for beginners who want to understand the use-case of docker i.e why do we require docker in our project?. Before learning any tool it’s very important to understand why do we need that tool in the first place.

Let’s understand this with an example. Imagine that we have built an e-commerce web app using MERN architecture and now we want to deploy our project. We have various deployment options in the market like AWS EC2 ( IaaS Providers), Heroku, Netlify (PaaS Providers).

Deployment basically means moving our project from the local development server to the production server. Can’t we just copy our project files from the local development server and paste them into the production server ?. NO! Understand this with the following example.
Say if we have an image A and we want to transfer this image to another computer. Let’s say we have transferred this image to another computer. Can we view this image on another computer now?. No, to view this image on another computer we’ll have to install an image viewing software as well. Similarly, just transferring the project files from the local development server to the production server will not work. In order for our project to work in the development server, we will have to install all the dependencies of our project in the development server.

Imagine now, our project demands surge up, and in order to meet these demands, we need to scale up and set up hundreds of servers. In order to set all these hundred servers up, we will have to install dependencies in all these hundred servers one by one. I guess now you can feel how redundant this task of installing these dependencies can be.

Can we not automate this task? Can we not write some script that will automatically install these dependencies and set our server up? Just imagine how beautiful it would be? How much time such a script or tool can save in the deployment process. Here’s come docker in rescue.

Docker is a dependency packaging tool. It packages our project dependencies into a single image/container. Now, whenever we want to deploy our project anywhere we will transfer this image/container to our production server instead of transferring our project files.

Now that’s a very basic introduction of docker. This introduction was just to make you understand why we need docker. There’s a lot more to it.

--

--