Nginx: [emerg] host not found in upstream when dockerizing a django/react project

Я пытаюсь докеризировать проект django/react, но сталкиваюсь с этой ошибкой при запуске docker-compose up. Я не понимаю, откуда берется эта ошибка. Я новичок в docker. Моя цель - развернуть фронтенд и бэкенд отдельно на одном сервере.

nginx: [emerg] host not found in upstream
 [emerg] 1#1: host not found in upstream "backend:8000" in /etc/nginx/conf.d/default.conf:2
nginx_1     | nginx: [emerg] host not found in upstream "backend:8000" in /etc/nginx/conf.d/default.conf:2

вот мой код

django's Dockerfile

ENV DJANGO_SECRET_KEY $DJANGO_SECRET_KEY
ENV DJANGO_CORS_ORIGIN_WHITELIST $DJANGO_CORS_ORIGIN_WHITELIST
RUN mkdir /backend
WORKDIR /backend
COPY requirements.txt /backend/
EXPOSE 8000
RUN pip install -r requirements.txt
COPY . /backend/
RUN python manage.py makemigrations
RUN python manage.py migrate

react's Dockerfile

FROM node
USER root
WORKDIR /frontend
COPY . /frontend
ARG API_URL
ENV REACT_APP_HOST_IP_ADDRESS $API_URL
RUN yarn
RUN yarn config set ignore-engines true
RUN yarn build 

конфигурация сервера

upstream api {
    server backend:8000;
}

server {
    listen 8080;

    location /api/ {
        proxy_pass http://api$request_uri;
    }

    # ignore cache frontend
    location ~* (service-worker\.js)$ {
        add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        expires off;
        proxy_no_cache 1;
    }

    location / {
      root /var/www/frontend;
      try_files $uri $uri/ /index.html;
    }

}

docker-copose.yml


version: '3'

services:

  
  backend:
    build:
      context: ./ruelle_backend
      args:
        DJANGO_ALLOWED_HOSTS: http://ruelle-online.fr
        DJANGO_SECRET_KEY: anis1807
        DJANGO_CORS_ORIGIN_WHITELIST: http://ruelle-online.fr
    command: gunicorn ivan_backend.wsgi --bind 0.0.0.0:8000
 
    ports:
      - "8000:8000"
  frontend:
    build:
      context: ./ruelle_frontend
      args:
        API_URL: http://ruelle-online.fr
    volumes:
      - build_folder:/frontend/build
  nginx:
    image: nginx:latest
    ports:
      - 80:8080
    volumes:
      - ./webserver/nginx-proxy.conf:/etc/nginx/conf.d/default.conf:ro
      - build_folder:/var/www/frontend
    depends_on:
      - backend
      - frontend
volumes:
  build_folder:

Вернуться на верх