I want to add sample data into mongoDB container when initialize. But when I get into mongdb shell, I am not able to find my collection/table. Did I set anything wrong? How do I pre-load the sample data correctly?
Thanks for any help.
test> show dbs
admin 8.00 KiB
config 12.00 KiB
local 8.00 KiB
Here is part of my docker-compose
file.
mongo:
image: mongo:7.0-rc
volumes:
- ./test/fixtures/mongo:/docker-entrypoint-initdb.d
command: bash -c "mongod --bind_ip=127.0.0.1 --port=27017 && mongoimport --host mongodb --db sampleDB --collection reviews --file /docker-entrypoint-initdb.d/sample.json --jsonArray"
sample.json
file
[
{"id":"a1" , "country":"US"},
{"id":"b2" , "country":"JP"},
]