小编Ehs*_*nia的帖子

django 测试无法在 gitlab ci 中启动

我在这个项目中使用了 docker 和 django,并且 gitlab ci/cd pipleline 和测试甚至无法启动和退出,出现以下错误:

测试一直在运行,直到我在 django 应用程序中添加一些测试,然后它失败了。


django.db.utils.OperationalError: could not translate host name "db" to address: Name or service not known
Run Code Online (Sandbox Code Playgroud)

这是我的 Dockerfile

FROM python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
Run Code Online (Sandbox Code Playgroud)

我的 docker-compose.yml:

version: "3.9"

services:
  db:
    image: postgres
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on: …
Run Code Online (Sandbox Code Playgroud)

python django postgresql docker gitlab-ci

5
推荐指数
1
解决办法
707
查看次数

标签 统计

django ×1

docker ×1

gitlab-ci ×1

postgresql ×1

python ×1