Uvicorn does not reload when changes on docker mounted volume in WSL #1893
-
I'm currently using Uvicorn through FastAPI. I start my project using docker compose, latest version. It seems there is an issue detecting the files that changed on a mounted volume. In my Dockerfile, I have set The command used to launch Uvicorn is And my code is under ./src/backend/app, mounted to /app/ inside the container What is weird, is that using watch('/app') directly from a python shell inside the container, the changes are logged correctly. Here are some logs docker compose up logs
docker compose exec backend python logs, run in parallel with above command
Any ideas if I'm missing something in the uvicorn command ? I tried to launch programmatically, but the logs are the same
Thank you in advance for any idea |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'd try first without the reload_dirs kwarg |
Beta Was this translation helpful? Give feedback.
-
Hello, Changing the workdir to /app, setting PYTHONPATH to /, and launching with |
Beta Was this translation helpful? Give feedback.
Hello,
I finally solved this.
The issue is that the working directory inside the Docker container was /, and it seems that reloading does not work in that case.
Changing the workdir to /app, setting PYTHONPATH to /, and launching with
uvicorn app.main:app --host 0.0.0.0 --port 8080 --reload
works as intended.