I started this weekend with a simple goal: set up a local development environment. I wanted a vanilla HTML/JS frontend, a Node.js backend, and a MongoDB database running in a Docker container (plus Mongo Express to visualize the data).
Prior to this, I had zero knowledge of JavaScript. I was just following a video tutorial, copying code I didn't fully understand, and hoping for the best.
I thought it would take an hour. Instead, it took a frustrated bike ride home, a Sunday spent journaling, and a deep dive into how Docker actually works to get it running. Here is the full story.
The Setup (Copying blindly)
I started by copying the frontend code. It was a simple User Profile page where you could toggle between "View" and "Edit" modes.
My index.html:
<script>
function saveProfile() {
document.querySelector('#name').textContent = document.querySelector('#input-name').value
// ... more DOM manipulation
}
</script>
My server.js:
var express = require('express');
var app = express();
app.use(express.static(__dirname));
app.listen(3000, function () {
console.log("app listening on port 3000!");
});
So far, so good. The frontend worked. Then came Docker.
Phase 1 The "Name Does Not Resolve" Loop:
I pulled the mongo and mongo-express images and tried to run them using long CLI commands I found online. I checked docker ps, and everything looked fine.
But when I checked the logs for Mongo Express, I saw this error over and over:
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
I spent 30 minutes spinning up containers, deleting them, and spinning them up again. I eventually turned to AI for help. It suggested I stop everything, wipe the containers, and create a dedicated network.
I ran:
docker network create mongo-network
Then I restarted the containers attached to that network. The error persisted. I was stuck in a loop of trying random commands without understanding why they failed.
Phase 2: The Mystery of "Pass" vs "Password"-
Once I finally got the containers talking, I couldn't log in to Mongo Express.
I had explicitly set my environment variables to:
ME_CONFIG_BASICAUTH_USERNAME=adminME_CONFIG_BASICAUTH_PASSWORD=password
But every time I tried to log in with admin / password, it failed.
After a lot of trial and error, I tried logging in with pass. It worked.
I realized that because of how I was passing arguments in PowerShell, Docker wasn't picking up my password variable. It was defaulting to the container's built-in security settings (admin:pass). I had to completely restructure my docker run command to ensure the variables were actually being read.
Phase 3: The Saturday Night "Vibecoding" Crash-
By 9 PM on Saturday, I hit a wall.
I ran my Node.js server and tried to edit a profile. The terminal said:
Connecting to the db....
And then... silence. It just froze.
I tried everything the AI suggested, but nothing worked. I didn't even understand half the commands I was typing. I realized I was just "vibecoding" typing random things hoping for a miracle. I was frustrated. I packed up, left the office, and took a bike ride home to clear my head.
Phase 4: The Monday Morning Fix
On Sunday, I didn't touch the code. I just journaled. I wrote down a plan: Understand the problem, then fix it.
On Monday, I came back fresh. I wiped every container and image (docker system prune) and started from scratch.
The "Windows Hang" (IPv4 vs IPv6)
I realized why the app was freezing. On Windows, localhost often resolves to the IPv6 address ::1. However, Docker Desktop for Windows listens on the IPv4 address 127.0.0.1.
My Node app was knocking on the IPv6 door, but Docker was at the IPv4 house.
I changed my connection string in server.js:
-
Bad:
mongodb://admin:password@localhost:27017 -
Good:
mongodb://admin:password@127.0.0.1:27017
The Version Mismatch
Even with the connection fixed, I got errors. I looked at my package.json.
I had installed the latest mongodb version (v6.0+), which uses Promises. But the tutorial code I copied was written for version 3.8, which used Callbacks.
I uninstalled the new version and forced a downgrade:
npm install mongodb@3.7.3
I restarted the server. I clicked "Save Profile." It worked.
Conclusion
This project was supposed to be a quick setup, but it turned into a crash course in DevOps. I learned:
-
Don't trust
localhoston Windows. Always use127.0.0.1. - Check your dependencies. Copy-pasting old code requires old packages.
- Stop "Vibecoding." If you don't understand the command, don't run it. Step back, journal, and come back fresh.
Top comments (0)