简体   繁体   English

Dockerfile 中的 mongorestore 未找到转储文件

[英]mongorestore in Dockerfile not locating dump files

Been trying to land this Dockerfile to work properly but seems there's no human way for me to do so.一直试图让这个 Dockerfile 正常工作,但似乎没有人为的办法让我这样做。

The directory where the Dockerfile is placed looks like this: Dockerfile所在的目录如下所示:

my_dir
  |
  |- Dockerfile
  |- samplesdb
  |- samplesdb/samples.bson
  |- samplesdb/samples_metadata.json

Now, the Dockerfile looks like this:现在,Dockerfile 看起来像这样:

FROM mongo

COPY . /dump/

WORKDIR /dump

CMD mongorestore --host 127.0.0.1 --port 27017 --db samplesdb --drop samples

However, it will always Failed: mongorestore target 'dump' invalid: stat dump: no such file or directory .但是,它总是Failed: mongorestore target 'dump' invalid: stat dump: no such file or directory

Is there any reason for this?这有什么原因吗? How should I copy those dumps?我应该如何复制那些转储?

mongorestore looks for a dump directory in your current directory, if it is named something else, you need to explicitly specify it as the last argument. mongorestore 在当前目录中查找转储目录,如果它被命名为其他名称,则需要将其显式指定为最后一个参数。

Your COPY command is creating /dump/samplesdb, however, mongorestore expects the bson files to be at the root of the dump directory您的 COPY 命令正在创建 /dump/samplesdb,但是,mongorestore 期望 bson 文件位于转储目录的根目录

So, change the below line:因此,更改以下行:

CMD mongorestore --host 127.0.0.1 --port 27017 --db samplesdb --drop samples

to (notice the samplesdb - your custom dump directory - as the last argument)到(注意 samplesdb - 您的自定义转储目录 - 作为最后一个参数)

CMD mongorestore --host 127.0.0.1 --port 27017 --db samplesdb --drop samples samplesdb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM