我试图从通过gitlab-ci-multirunner运行的码头图像中访问mongorestore/mongodump命令。如何访问码头图像中的mongorestore/mongodump
我.gitlab-ci.yml看起来是这样的:
image: node:7.2.0
cache:
key: "$CI_BUILD_REF_NAME"
paths:
- node_modules/
services:
- mongo
variables:
DOCKER_ENV: 'true'
NODE_ENV: 'test'
all_tests:
script:
- npm install
- npm install tsd -g
- tsd install --save
- node_modules/typescript/bin/tsc -p .
- node node_modules/mocha/bin/_mocha --recursive tests --timeout 15000
在我的测试我mongodump/mongorestore。我得到的错误是:
Create Transaction Tests
Connected to MongoDB: mongodb://mongo:27017/test-db { Error: Command failed: mongorestore --port 27017 --drop /builds/project/repo/project/tests/testData/db/mongo/dump
/bin/sh: 1: mongorestore: not found
我甚至尝试运行与脚本中的部分 “泊坞窗运行” 一mongorestore命令:
- docker run --rm --link mongodb:mongo -v /root:/backup mongo bash -c ‘mongorestore /backup --host $MONGO_PORT_27017_TCP_ADDR’
我得到这个错误:
/bin/bash: line 61: docker: command not found
我必须提到,我在gitlab提供的共享docker runner上运行此映像。
有关如何从我的测试中访问“mongorestore”命令的任何建议?
我可以问你是否想在节点码头集装箱中运行mongodump和mongorestore,因为这是它们在生产环境中的运行方式?还是只是为了测试,设置测试数据? –
仅用于测试和设置数据。 –
如果你在生产中不需要它们,那么也许你不应该让它们在你的容器中进行测试。值得研究[使用单独的容器来播种数据](http://stackoverflow.com/a/33397913),或者看看您是否可以使用标准mongo调用删除/创建测试数据。 –