Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

678
Views
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

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

CMD ["uvicorn", "main:app", "--host=0.0.0.0" , "--reload" , "--port", "8000"]

Your work directory is /app and the main.py file is already there .So you don't need to call app.main module. Just call main.py script directly in CMD.

over 4 years ago · Santiago Trujillo Report

0

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!