Mongodb collection lost after successful build

Hello community,
My data is deleted every day. The mongo server run under docker.
On the docker side:

The mongo setup is set to persistant data
volumes: - mongodata:/data/db

Thank you

do you use docker-compose ? Sounds like you are not persisting the volume. Use volumes | Docker Documentation. I think if you do a “docker-compose down -v” when you want to stop the containers it will wipe away the volumes.

Hello ,
Thank you for your reply, Yes, I am using docker compose as follows :
under the folder :/var/www/ and I have

mongo ( folder )
docker-compose.yaml
init-mongo.js
The docker-compose .yml file is :smile:

version:"3.7"
services:
         sar_data:
               image : mongo
               container_name: monogodb
                enviroment:
                             - MONGO_INITDB_ROOT_DATABASE=sar-mongo
                volumes:
                            - ./init-mngo.js:/doker-entrypoint-initdb.d/init-mongo-js:ro
                            - ./mongodb/data:/.. /.. /data/db
               ports:
                           - 27017:27017
        
And my init-mongo.js file is :
db = dv.getSiblingDB('sar_mongo')
db.createUser)
       { 
             user: 'root',
             pwd:  'admin',
             roles: [{role: 'readWrite', db : 'sar_mongo'}],
}
);