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 (1)
Nice writeup β creating the custom network first is the step people skip and then wonder why containers can only talk by IP. One thing I'd add for anyone extending this to a MERN setup: make sure your Node service's connection string uses the container name, not localhost, once it's containerized too, or you'll hit a connection refused that looks identical to a Mongo config issue.