1

我正在构建一个需要以 json 格式导出 mongodb 数据并将其作为 .zip 文件返回给 api 请求的 CMS。

我有一个名为“web”的服务,我需要运行

const child = exec(`mongoexport --db meanbase --collection pages --out ${path.join(this.app.get('exportPath'), 'pages.json')} --jsonArray`)

但是它返回代码 127 - 找不到命令。这是因为我的 mongoDB 服务在另一个容器中运行。

db:
  image: mongo
  expose:
    - "27017"
    - "37017"
  command: --smallfiles
web:
  build: .
  expose:
    - "80"
  env_file:
    - meanbase.env
  links:
      - db:db
nginx:
  build: nginx
  links:
    - web:web
  volumes_from:
    - web
  ports:
    - "80:80"

如何从我的 web 容器为 db 容器运行 mongoexport 并将其内容传递回 web 容器?还是有更好的方法来做到这一点?

4

1 回答 1

0

该错误是因为该命令在容器mongoexport中不存在。web您需要Dockerfile为该web服务安装它。

于 2016-09-14T15:30:58.310 回答