Hello MongoDB Community,
I’m facing an issue where data that I’m able to query and retrieve through a Flask application is not visible in MongoDB Compass. My setup includes a Flask application and MongoDB running in separate Docker containers, with the database data stored in a Docker volume.
Here’s the issue in detail:
- I can successfully register a user via a POST request to my Flask app’s
/register
endpoint. - I can retrieve this user using a
curl
command to the Flask app’s/users
GET endpoint. - The
curl
command returns the expected user data, indicating that the Flask app is able to interact with the MongoDB database correctly. - However, when I connect to MongoDB using Compass with the URI
mongodb://localhost:27017/
, theuserdb
database does not appear in the list of databases, nor do I see any collections or documents.
Relevant details of my setup:
- Docker Compose is used to orchestrate the containers.
- MongoDB is using the official
mongo:latest
image. - The
docker-compose.yml
file specifies themongodb_data
volume mapped to/data/db
. - Flask connects to MongoDB using the MongoClient with the URI
mongodb://mongo:27017/
.
Here’s what I’ve checked so far:
- The MongoDB service in Docker Compose is running without errors.
- There are no filters set in MongoDB Compass that would hide the database.
- I have refreshed and restarted MongoDB Compass several times.
- The Docker volume appears to be correctly mapped and persisting data.
I’m puzzled as to why MongoDB Compass does not show the userdb
database or its collections, while the data is clearly present and accessible to my Flask app. Has anyone encountered a similar issue, or could you provide guidance on what might be going wrong?
Any insights or suggestions would be greatly appreciated!