'ModuleNotFoundError: No module named 'app' fastapi docker
FROM python:3.8
WORKDIR /app
COPY requirements.txt /
RUN pip install --requirement /requirements.txt
COPY ./app /app
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host=0.0.0.0" , "--reload" , "--port", "8000"]
when i used
docker-compose up -d
ModuleNotFoundError: No module named 'app'
the folders in Fastapi framework:
fastapi
app
-main.py
-
language_detector.py Dockerfile
docker-compose
Solution 1:[1]
Try creating the /app folder before
FROM python:3.8
RUN mkdir -p /app
WORKDIR /app
COPY requirements.txt /
RUN pip install --requirement /requirements.txt
COPY ./app /app
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host=0.0.0.0" , "--reload" , "--port", "8000"]
And launching it:
docker-compose up --build
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | a.civit |
