Before running Docker Compose, delete the old containers that were previously created so there are no port conflicts. Then run the compose command.
After running, visit:
localhost:8081The same Mongo Express UI will open. We can create our database, add collections, and add documents just as before.
If everything is working correctly:
Create a database named:
college-dbInside college-db, create a collection:
usersInsert a sample document:
{
"email": "john@yahoo.in",
"username": "JohnDoe",
"password": "secret"
}Now send a GET request to:
localhost:5050/get-usersThe data will be visible in the response.
This confirms:
We now have a fully working system:
All components are connected and working together without installing MongoDB locally.