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

a 夏天 提交于 2019-12-14 02:25:46

问题


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


来源:https://stackoverflow.com/questions/47416987/mongoimport-docker-failed-error-connecting-to-the-db-server-no-reachable-serve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!