Python - Docker socket hang up after first successful API call, docker exits mid way through second call

Trying a python program, using hugging face transformers & faiss. I was able to use the API successfully while testing locally. But while testing the same inside docker, the api executes successfully the first time & the I get a Error : Socket hang up when trying via postman. Post which the docker exits.

What I have tried so far:

  1. Adding ‘/’ at the end of the URL
  2. Adding host = ‘0.0.0.0’
  3. Trying torch version == 1.11.0
  4. Changed Postman timeout settings & Max response size & Unchecked ‘Send Postman token header’
  5. Tried the API using Thunder Client & cURL.

Docker File :

FROM python:3.8.0
COPY . .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
RUN python3 -m spacy download en_core_web_sm
CMD [ "python3", "-m" , "flask", "run", "--host", "0.0.0.0", "--port=8002"]
EXPOSE 8002