As a newbie of Docker, I tried to build a mongoDB Docker container containing some sample data by means of docker-compose.yml
in the working directory.
My mongo/Dockerfile
contains following code:
FROM mongo:latest
ADD shops.json /home/
RUN mongoimport --db masterdata --collection shops --file /home/shops.json
In the last line, sample data would be imported to mongoDB.
My docker-compose.yml
contains the following code:
version: '3'
services:
mongo:
build: mongo
ports:
- "27017:27017"
With the configuration above, I tried to build the MongoDB docker container and got error:
Failed: error connecting to db server: no reachable servers
This problem looks similar with mongoimport Docker Failed: error connecting to the db server: no reachable servers, but I really tried every suggestion given in mongoimport Docker Failed: error connecting to the db server: no reachable servers and am never able to resolve this error.
So anyone can help on this?