But it works on my machine🤷♂️

One of the most common issues we face during project collaboration is environment mismatch—it works on one machine but fails on another. This can quickly become a major headache, especially in teams.
Let’s explore how Docker can help us eliminate this problem by providing a consistent and isolated environment for our applications.
To begin, let’s understand some fundamental concepts of Docker.
🚢 What is Docker?
Docker is a platform that allows you to package, ship, and run applications inside lightweight, isolated environments called containers.
🎯 Why Do We Need Docker?
Let’s say you’ve built an app on your machine (it works perfectly), but when you give it to your teammate or deploy it on a server:
It fails due to missing dependencies
It works on your OS but not theirs
Different services use different versions of Node/Python/Java
Managing multiple environments becomes a headache
❌ This problem is famously known as: "It works on my machine" problem.
✅ Docker solves this by:
Without Docker | With Docker |
Setup takes hours | One command: docker run ... |
App might crash due to OS issues | Runs the same across all systems |
Needs manual dependency install | All dependencies are packed in one image |
Multiple apps conflict | Each app runs isolated in its container |
📦 What Does Docker Actually Do?
Docker creates a container that:
Has your app code
Includes all dependencies (Node.js, Python, Java, etc.)
Runs on any system with Docker installed (Linux, Windows, Mac)
Think of it as a mini virtual machine but much lighter and faster.
🧠 How Docker Works (Conceptually)
1. Dockerfile: Your Recipe 📄
You write a Dockerfile
that tells Docker:
What base OS/language to use
What dependencies to install
How to run your app
Example:
FROM node:18
WORKDIR /app
COPY . .
RUN npm install
CMD ["node", "index.js"]
2. Docker Image: Your App’s Blueprint 📦
Docker reads the Dockerfile and builds an image: a snapshot of your entire app environment.
Command:
docker build -t my-app .
3. Docker Container: Your App in Action 🏃♂️
You run that image, and Docker starts a container — a running instance of your app.
Command:
docker run -p 3000:3000 my-app
It's like baking a cake (image) and then serving it on plates (containers).
🕹️ When Should You Use Docker?
Use Case | Should You Use Docker? |
Developing microservices | ✅ Yes |
Running the same app on multiple servers | ✅ Yes |
Avoiding environment conflicts | ✅ Yes |
Building CI/CD pipelines | ✅ Yes |
Learning a new tech temporarily | ✅ Yes (spin up fast) |
Hosting static HTML pages | ❌ Not necessary |
Very small hobby project on localhost | ❌ Optional |
🚀 Real Example
Let’s say you're working on a Java Spring Boot app and your friend is using Node.js and you also need MySQL.
Without Docker:
You’ll need to install Java, Node.js, and MySQL on your machine
Configure each one separately
Handle version mismatches
With Docker:
You run
docker-compose up
Docker brings up:
Java Spring app
Node.js order service
MySQL DB
And they all talk to each other easily!
🧪 In Short:
🧊 Docker = "I don’t care where it runs — just give me a consistent, isolated, reliable environment!"
Subscribe to my newsletter
Read articles from Vishal Jha directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
