Docker Community Forums

Share and learn in the Docker community.

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

docker

(Vikranth493) #1

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


(Sam) #2

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


(Vikranth493) #3

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.


(Sam) #4

understood… you use mongodump and they use mongorestore