erny
erny

Reputation: 2499

Restore mongo dump in docker container returns "Failed: EOF"

When trying to restore a mongo dump created with:

docker exec mongo sh -c "mongodump --db=prod --archive --gzip" > file.dump.gz

using the command line:

docker exec mongo sh -c "mongorestore --archive --gzip --db=prod --drop" < file.dump.gz

I get the following output:

2021-01-20T18:39:33.129+0000    Failed: EOF
2021-01-20T18:39:33.129+0000    0 document(s) restored successfully. 0 document(s) failed to restore.  

Upvotes: 2

Views: 1002

Answers (1)

erny
erny

Reputation: 2499

It seems that mongorestore can't access correctly stdin if you don't tell docker to allocate stdin with the -i flag, so the command should look like this:

docker exec -i mongo sh -c "mongorestore --archive --gzip --db=prod --drop" < file.dump.gz

Upvotes: 3

Related Questions