Last active
February 27, 2019 13:57
-
-
Save sepastian/878bd589d33a70e95deecbf6a40ee726 to your computer and use it in GitHub Desktop.
Docker: mongoimport data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming there's a Docker container runninng Mongo, named `mongo1`, | |
# fire up another container `mongo2`, | |
# mounting a directory containing data to import, | |
# and execute `mongoimport` inside `mongo2`, | |
# to import data into `mongo1`. | |
# Start `mongo2`: | |
# link it to the running `mongo1`; | |
# open a bash session; | |
# mount pwd to /import; | |
# remove when done. | |
docker run --rm -it --link mongo1 --network my_network -v $(pwd):/import mongo:3 /bin/bash | |
# Now, inside `mongo2`, run `mongoimport` | |
# to import data from a file into `mongo1`. | |
mongoimport --uri mongodb://mongo1/db?replicaSet=rs --drop --collection=some_collecdtion /import/some_file.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment