mongoimport Docker Failed: error connecting to the

2019-07-23 19:50发布

问题:

I am trying to create a Docker container with MongoDB and import data into it. I have tried using the following dockerfile:

FROM mongo

# This will be created if it doesn't exist
WORKDIR /app/data/

# Copy dependency definitions
COPY mydata.csv .

ENTRYPOINT mongod

# Import data
RUN mongoimport --host=127.0.0.1 -d mydb -c reports --type csv --file mydata.csv --headerline

I get the following error:

Failed: error connecting to the db server: no reachable servers

Any suggestions? Thanks!

回答1:

Try this :

mongoimport --host 127.0.0.1 --port <specifyPort> -d mydb -c reports --type csv --file mydata.csv --headerline