I use "mongoDB" image in docker-container. When I run command for export DB to csv:
docker exec -i 418f46e5595d mongoexport --db saveInfo --collection infoobjects --type=csv --fields _id,postLink,postTitle,contactPhone --out ./info.csv
File saved in folder where container is working. How can I save it on my machine?
My decision:
1) export
docker exec -i 418f46e5595d mongoexport --db saveInfo --collection infoobjects --type=csv --fields _id,postLink,postTitle,contactPhone --out ./info.csv
2)copy to my machine
docker cp webspider_mongo_1:/data/info.csv .
remove the
--out
option so it will export tostdout
and redirect output to a file, something like this:You might want to redirect error messages to a different stream, so: