There's always that moment when a fellow developer tells you pull the latest code and run it, you do exactly that and it doesn't work.
- what version of node are you using ?
- what database did you install? And suddenly we are now debugging you computer instead of the application. Let's see exactly how this happens
Imagine you are building a NodeJS application in your computer and on you computer you have NodeJS Version 22, Postgresql 16, redis and several other dependencies and this point everything works on your computer. Then your teammate downloads same project but they have NODEJS Version 20, a different Postgresql version 14 and they are missing on of your dependencies. Now suddenly the same code will behave differently. The problem isn't necessarily your code but the environment so how do we fix this?
Engineers asked why if we could package the application together with everything it needs to run, that is the application, it's dependencies, it's runtime, it's configurations and the run it anywhere, that idea has a name and it's called CONTAINERIZATION.
so what's a CONTAINER? this is basically an isolated environment that packages an application together with everything it needs to run. And now you are curious who actually builds and runs these containers. Let me introduce you to a tool known as DOCKER. Docker is one of the most popular tools for creating and running containers, but not this Docker doesn't just guess what to place inside your box, you have to actually define what goes inside the box and that definition is called a DOCKER FILe. This file tells the docker how to build the environment, start with NODE 22 create an application directory, install the dependencies, copy the application then tell it how to start. Once Docker follows those instructions it packs everything inside the box. That packed box before anyone opens it it's called AN IMAGE so practically its a read only template that's built from your docker file instructions.
so technically a container is a running instance of an image. So what does these actually solve?
Your teammate doesn't need to recreate your entire environment manually there's just need to open the same box you also deploy that same box to your server and now everyone is running the exact same packed environment but that doesn't mean every project needs to be dockerized. Docker shines when your app has dependencies or when your app has to run the same way across different machines or many developers
SO THE REAL SKILL IS NOT ACTUALLY KNOWING DOCKER BUT WHEN YOU ACTUALLY NEED IT
Top comments (0)