Hi, I’m Ahmed Salau, a DevOps enthusiast passionate about cloud and automation. In this project, I containerized an application using Docker, connecting a Node.js backend to a MongoDB database, and adding Mongo Express as a UI to manage the database, all running locally using Docker.
🚀 Why Docker?
Managing services like Node.js, MongoDB, and admin tools locally can become messy fast. Docker helps isolate and run everything in lightweight containers, making setup, testing, and teardown much easier.
🧰 Tech Stack
Docker – For containerization and orchestration
Node.js – Backend application
MongoDB – NoSQL database
Mongo Express – Web-based MongoDB UI
HTML, JavaScript - Frontend
project-root/
│
├── images/
│ └── profile-1.jpg
├── index.html
├── serverlocal.js
└── README.md
🛠️ Setup Process
Pull Required Docker Images
Before running containers, Docker must download the necessary images from Docker Hub. Example: I used the following commands to pull the images I needed manually
docker pull mongo
docker pull mongo-express
Docker will also pull these images automatically the first time you run the containers, but it's good practice to be explicit when setting things up. Visit - https://hub.docker.com/
🔹 Step 1: Create a Custom Docker Network
This network allows all containers to communicate by name instead of IP.
--network mongo-network
If you create a network: Containers communicate by name, easier to manage and more reliable.
Note: By default, when you run Docker containers, Docker automatically connects them to a default network called bridge. On this network, containers can communicate with each other only by IP address, which can be inconvenient and less reliable because container IPs can change.
If you don’t create a custom network and just run the containers, they are still technically “networked,” so your Mongo Express container can reach MongoDB by IP, but you’d have to manage IP addresses manually, which is cumbersome.
🔹 Step 2: Start MongoDB in a Container
This creates a MongoDB container and connects it to the custom network.
docker run -d \
--network mongo-network \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
--name mongodb \
mongo
🔹 Step 3: Deploy Mongo Express for UI Access
Mongo Express provides a web-based interface to interact with the MongoDB container.
docker run -d \You can now access Mongo Express at:👉 http://localhost:8081
--name mongo-express \
--network mongo-network \
-p 8081:8081 \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=admin \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=password \
-e ME_CONFIG_MONGODB_SERVER=mongodb \
mongo-express
🔹 Step 4: Run the Node.js Backend Locally
Once your MongoDB and Mongo Express containers are running, start your backend app: node server.js
The app should now be running on: 👉 http://localhost:3000
💡 Key Learnings
- Docker Networks make container communication seamless.
- Mongo Express simplifies database management during development.
- Dockerizing the database layer avoids local setup conflicts.
This approach is easily scalable and mirrors production environments.

📌 Conclusion
This project highlights the value of using Docker in backend development. By containerizing your database and admin tools, you isolate concerns and streamline your workflow. Whether you're learning DevOps or building robust systems, this approach offers clarity and control.
Thanks for reading!
I'm happy to answer any questions you may have — just ask!.
Follow my journey as I continue exploring DevOps, cloud-native development, and containerization tools.
Let’s connect and grow together! 🚀
🎥


Top comments (0)