'docker-compose exited with code 1 Errno 2 Name or Service not known

I'm following along with a tutorial and when I go to run docker-compose up it exits with code 1.

docker-compose.yml

services:
  web:
    build: ./project
    command: uvicorn app.main:app --reload --workers 1 --host 0.0.0.0. --port 8000
    volumes:
      - ./project:/usr/src/app
    ports:
      - 8004:8000
    environment:
      - ENVIRONMENT=dev
      - TESTING=0

Dockerfile

FROM python:3.10.1-slim-buster

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN apt-get update \
&& apt-get -y install netcat gcc \
&& apt-get clean

RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt

COPY . .

Logs

INFO:     Will watch for changes in these directories: ['/usr/src/app']
ERROR:    [Errno -2] Name or service not known

The docker-compose is in a root folder with a project directory next to it. The Dockerfile is in that project directory.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source