Before we start learning about Docker, it is crucial to understand why exactly we need it — what problems exist in our current software development process that Docker was created to solve.
Let's take a very basic example. Suppose we are trying to develop a Node.js based application. Generally, if we are building a Node.js application, we would have already installed Node on our system. Let's assume we installed Node version 16, and along with that, we are also using MongoDB as a database, so we installed MongoDB version 4.2. This is our local development environment in which we are building our application.
When we talk about personal projects or small-scale projects, we generally don't encounter too many problems. The problems that Docker is designed to solve usually arise in large organizations or when there are many members in a team, all working on the same application.
Let's assume we are working in an organization, in a team, and a new member joins who has a Mac OS system. They now want to replicate the entire setup on their own system so they can also work on the same application. This member is going to manually install all the dependencies one by one. They start with Node — maybe a newer version is available, so they install Node version 20. Similarly, they install MongoDB — maybe a newer version exists, so they install MongoDB version 6. And this is how they set up the entire environment on a different machine.
When we try to replicate a local development environment from one machine to another, there are some common problems we can encounter:
This problem gets harder as the team grows. With two or four people, it's easy to solve. But when talking about larger teams where many members are working on the same application, the development process can become very error-prone.
This gives rise to a very classical problem in software development known as:
"It works on my machine"
It is to solve this specific problem that tools like Docker were needed.