Disclaimer: I am pretty green with Docker and gunicorn. I am running a Flask application inside a docker container. I am running the following:
docker run --runtime=nvidia -it my-image:0.1
and in the logs:
[2019-09-18 18:02:21 +0000] [9] [INFO] Booting worker with pid: 9
usage: gunicorn [-h] [--model MODEL] [--cam_id CAM_ID] [--cam_width
CAM_WIDTH]
[--cam_height CAM_HEIGHT] [--scale_factor SCALE_FACTOR]
[--notxt]
gunicorn: error: unrecognized arguments: -b :8080 main:app
I know this question has been asked multiple times (here, here, and here for example) but none of the answers seemed to help.
Here is the content of my Dockerfile
:
FROM gcr.io/deeplearning-platform-release/pytorch-gpu.1-1
RUN apt-get update
ADD . /app
WORKDIR /app
RUN pip install --no-cache-dir -r requirements.txt
ENTRYPOINT ["gunicorn", "-b", ":8080", "main:app"]
and main.py
looks like this:
from flask import Flask, request
import model
app = Flask(__name__)
@app.route('/getduration', methods=['POST'])
def get_duration():
try:
video_url = request.args.get('video')
except:
video_url = None
try:
duration = model.run(video_url)
result = str(duration)
return result, 200
except Exception as e:
error = f"There was an error: {e}"
return error, 500
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8080, debug=True)
I've tried creating a wsgi.py file containing:
from main import app
if __name__=="__main__":
app.run()
then changed my Dockerfile entrypoint:
ENTRYPOINT ["gunicorn", "-b", ":8080", "wsgi:app"]
What am I missing?
Note that if I just run python main.py
inside my container, my flask app works fine. When I changed my Dockerfile
entrypoint to CMD ["python", "main.py"]
, the server runs, but I don't get any response when I make requests.