How to Demonstrate Scalability & Elasticity using Docker
- Sharon Rajendra Manmothe

- 7 hours ago
- 1 min read
STEP 1 — Create a Simple Web App
Create a folder:
scaling-demo/
└── app.js
└── package.json
└── Dockerfile
package.json
{
"name": "scale-demo",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.2"
}
}
app.js
const express = require("express");
const app = express();
const port = 3000;
app.get("/", (req, res) => {
const host = process.env.HOSTNAME;
res.send(`Hello from container: ${host}`);
});
app.listen(port, () => console.log(`App running on port ${port}`));
Dockerfile
FROM node:18
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["node", "app.js"]
STEP 2 — Build Docker Image
docker build -t scale-demo .
STEP 3 — Run SINGLE Container (No scaling yet)
docker run -p 3000:3000 scale-demo
Open browser → http://localhost:3000You will see:
Hello from container: <container_id>
STEP 4 — Add Load Balancer using Docker Compose
Create docker-compose.yml:
version: '3'
services:
app:
image: scale-demo
deploy:
replicas: 1
ports:
- "8080:3000"
Run it:
docker compose up --scale app=1
Access: http://localhost:8080
STEP 5 — SCALE UP (Show Scalability)
Increase containers from 1 → 3
docker compose up --scale app=3
Refresh your browser multiple times.You’ll notice the host name changing:
Hello from container: abc123
Hello from container: def556
Hello from container: ghi998
This proves scalability: more containers handle more load.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.



Comments