How to take dump(.sql) from the container(mongodb)?

Can anyone please tell me how to take dump from the running continer?

Like sql server we are taking dump like this
mysqldump -uroot -proot dbname > testdb.sql

not sure which question you are asking

to backup a mongo database, you would use the mongodump command
see https://docs.mongodb.com/manual/core/backups/#back-up-with-mongodump

now, how you connect to the container…
you either
docker attach if the container is on the host you are on
or
you can ssh to the container , if it has sh server running
or
you can use the mongo db ports for access

absolutely nothing here (access to container) is different than a normal database server

1 Like

Thanks sdetweil , I got it .

Basically what i mean is that i have mongodb container running with docker but my friend does not have. So i have to take a dump from the my docker container and restore it in my friend’s system.

understood… you use mongodump and they use mongorestore

1 Like