如何在Docker执行器中运行gitlab runner中的mongodb服务

我正在尝试在gitlab中build立pipe道 ,用mongodb作为数据库来testing在laravel中写的api 。 以下是我的.gitlab-ci.yml文件。

image: registry.gitlab.com/sadhu/web:latest services: - name: mongo:3.4.10 variables: MONGO_URI: 'mongodb://mongo/demo' stages: - test unit_test: stage: test script: - npm install - composer install - cp .env.testing .env - php artisan key:generate - php artisan config:cache - php vendor/bin/phpunit --coverage-text --colors=never 

但是unit testing的结果是负面的。 以下是我的unit testing的结果:

 1) TestBedApiTest::testDuplicateId Expected status code 409, got 500. Failed asserting that 500 matches expected 409. 

500错误大多出现在laravel api无法连接数据库时。 但是我不确定这是否是主要原因,我无法确定,如何确保这一点。

以下是我的.env.testing文件。

 APP_ENV=development APP_KEY=base64:fvuqjkl+g7MNIH2eC39Osp78feOfHhMDXPXSlKHlPD4= APP_DEBUG=true APP_LOG_LEVEL=debug DB_CONNECTION=mongodb DB_HOST=mongo DB_PORT=27017 DB_DATABASE=demo DB_USERNAME= DB_PASSWORD= 

有人可以告诉我如何在gitlab亚军启用mongodb服务?