I have a directory structure like this on the host (outside docker container):
docker_ml/
├── auth.conf
├── data_loader.py
├── db.py
├── docker-compose.yml
├── Dockerfile
├── Dockerfile2
├── __init__.py
├── ml
├── models.py
My Dockerfile has the important directives relative to this problem:
WORKDIR /project
And the docker compose this:
command:
["uvicorn", "ml:app", "--host", "0.0.0.0","--port","9001","--reload"]
volumes:
- .:/project/ml
So essentially I am mounting a volume where of my application at /project/ml in the docker container and I run the command "uvicorn", "ml:app", "--host", "0.0.0.0","--port","9001","--reload" at the directory entrypoint which is /project.
The uvicorn servers starts fine but __init__.py has the following relative imports:
from .db import engine
And I get the following error:
ModuleNotFoundError: No module named 'db'
What am I doing wrong here ?