Mongodb gitlab CI docker连接被拒绝

问题描述 投票:0回答:1

我正在尝试为我们的开源爱好项目创建一个docker测试环境。我们的python和angular代码正在运行,没有错误。我需要配置dockerRunner使其包含mongodb的帮助。

stages: 
- build
- test

services:
  - mongo

variables:
  MONGODB_URI: "mongodb://mongo/projekt_eszkozok"


build: 
  stage: build
  image: "python:3.8.2"
  script:
    - "pip3 install -r sources/backend/requirements.txt"

test:
  stage: test
  image: "python:3.8.2"
  script:
    - "pip3 install -r sources/backend/requirements.txt"
    - cd sources/backend
    - "python -m unittest discover tests/"

错误:

pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

另外,一旦我们进行了第一个Angular测试,该项目就将Angular前端添加到测试环境中也可能很重要。

Python数据库配置:

MONGODB_SETTINGS = {
    'host': 'mongodb://127.0.0.1:27017/projekt_eszkozok'
}

也尝试过:

MONGODB_SETTINGS = {
    'host': 'mongodb://mongo:27017/projekt_eszkozok'
}
python mongodb docker open-source gitlab-ci
1个回答
0
投票

如yippie-flu和Vishesh Kumar Singh在MongoDB server doesn't start at gitlab runner using gitlab-ci中回答,而不是localhost:27017,您必须使用mongo:27017,因为mongo服务正在其自己的Docker容器中运行。

© www.soinside.com 2019 - 2024. All rights reserved.