I’m running a MongoDB server using Docker. The data is being saved initially, but after some time, it gets lost even though a volume is attached. Docker has not been restarted during this period. Any ideas on what might be causing this?
I am using FastAPI for my backend and Motor to configure MongoDB. My code does not include any commands to delete data. Here is a relevant code snippet:
import motor.motor_asyncio
import os
class MongoDBClient:
def init(self):
URI = “mongodb://localhost:27017”
# Create a MotorClient
self.client = motor.motor_asyncio.AsyncIOMotorClient(URI)
# Access the specific database
self.db = self.client[mongodb_config[‘db’]]
async def get_collection(self, collection_name):
return self.db[collection_name]
I expected the data to persist, but it seems to disappear after some time, even though no delete operations are being performed.
Jagdish Songara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.