. How to run uvicorn inside Dockerfile? #8115
-
Description How can run uvicorn and -e etc inside Dockerfile in Win 10:
inside Dockerfile
so that
encapsulates these environment variables in CLI command? Looked at these examples but dont show: https://medium.com/@williamhayes/fastapi-starlette-debug-vs-prod-5f7561db3a59 "Uvicorn documentation indicates you have to run uvicorn from the command line for the debugging/auto-reloading feature to work. It can’t be run programmatically either." ??? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Note that you are overriding ENTRYPOINT and CMD with an empty command! Which comes from Anyway, if you still want to override that, set the CMD to be something like |
Beta Was this translation helpful? Give feedback.
-
Yep, exactly, as @HacKanCuBa says. You don't need to specify a custom command or entrypoint in your Dockerfile. |
Beta Was this translation helpful? Give feedback.
-
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues. |
Beta Was this translation helpful? Give feedback.
Note that you are overriding ENTRYPOINT and CMD with an empty command! Which comes from
CMD ["/start.sh"]
=>start.sh
which actually runs Gunicorn with Uvicorn workers (the recommended way to run Uvicorn in production). Try removing ENTRYPOINT and CMD from your Dockerfile.Anyway, if you still want to override that, set the CMD to be something like
uvicorn --reload your_app.app:app
:CMD ["uvicorn", "--reload", "your_app.app:app"]
.