We have a very simple service called Learning Locker that we have built into one of our sites, it’s a PHP Front End with no Volumes, backed by MongoDB with a single volume (that contains information). Here’s how we originally created it:
docker run -d --name db -p 27017:27017 -p 28017:28017 mongo:3.2.21-jessie docker run -d --name learninglocker --restart always --link db:mongo -p 8080:80 sproutlabs/learninglocker:latest
Nice and simple. So I need to move the mongo docker container to a different server. I was reading through the official docs that details this, but it’s not working as expected.
So first I attempted to just copy the files outright with tar:
docker run --rm --volumes-from db -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /data/db/
And then import it:
docker run --rm --volumes-from db -v $(pwd):/backup ubuntu bash -c "cd /data/db && tar xvf /backup/backup.tar --strip 1"
But that obviously didn’t work, because MongoDB isn’t aware of the database itself. So then I considered running mongodump in the source container with:
docker exec -it db cd /data/db/ && mongodump --database=learninglocker
And then migrating the entire directory over just as above. Except weird result the dump folder that is present in the source container and tar file aren’t in the destination. So how should I go about this final step of getting the
/data/db/dumps folder over to the new container and run
mongorestore with it?
I appreciate the help, thanks.