With docker, pseudo-tty allocation is deactivated by default, but the -i (interactive) option is required with the restore command.
-
No Auth :
docker exec <mongodb container> sh -c 'mongodump --archive' > db.dump
-
Authenticated :
docker exec <mongodb container> sh -c 'mongodump -d <database> -u <user> -p <password> --archive' > db.dump
-
No Auth :
docker exec -i <mongodb container> sh -c 'mongorestore --archive' < db.dump
-
Authenticated :
docker exec <mongodb container> sh -c 'mongorestore -d <database> -u <user> -p <password> --archive' < db.dump
With docker-compose, pseudo-tty allocation needs to be deactivated explicitly each time with -T :
docker-compose exec -T <mongodb service> sh -c 'mongodump --archive' > db.dump
docker-compose exec -T <mongodb service> sh -c 'mongorestore --archive' < db.dump
That's all ! ✨🎉 Now, feel free to write a script and add it to your pipeline.