Error: Got unexpected extra argument (/start-reload.sh) When setting Development live reload for FastAPI docker

Viewed 1353

Following the documentation in uvicorn-gunicorn-fastapi-docker I should run my image by running:

docker run -d -p 80:80 -v $(pwd):/app myimage /start-reload.sh

But I get:

Usage: uvicorn [OPTIONS] 
Try 'uvicorn --help' for help.

Error: Got unexpected extra argument (/start-reload.sh)

I managed to mount a volume by using what I found here Debug mode? but I think it is not elegant enough and I have to run it every time I make a change (at least I dont have to build the image)

docker run --name ${containerName} \
--env GUNICORN_CMD_ARGS="--reload" \
-p 5000:5000 \
-v $(pwd)/app:/app \
${imageName}:${versionTag} 

My Dockerfile it is just:

FROM tiangolo/uvicorn-gunicorn-fastapi:latest

EXPOSE 5000

COPY ./app /app

ENTRYPOINT ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"]

And It works as supposed.

It is possible to be able to reload as I changing my code?

1 Answers

Simply add --reload to entrypoint worked for me:

ENTRYPOINT ["uvicorn", "main:app", "--reload","--host", "0.0.0.0", "--port", "5000"]
Related