I have a simple flask app that works without docker but doesn't reply when being wrapped in docker container. I suspect I have some addresses messed up
from flask import Flask, render_template, request
import pandas as pd
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def uploadfile():
    if request.method == 'POST':  # check if the method is post
        df = pd.read_json(request.files.get('file'))
        return render_template('upload.html',  tables=[df.head().to_html(classes='data', header="true")])
    return render_template('upload.html')
if __name__ == '__main__':
    app.run(debug=True, port=5000)  # running the flask app
upload.html
<!doctype html>
<html>
  <head>
    <title>File Upload</title>
  </head>
  <body>
    <h1>File Upload</h1>
    <form 
      method="POST" 
      action="/" 
      enctype="multipart/form-data"
    >
      <p><input type="file" name="file"></p>
      <p><input type="submit" value="Submit"></p>
    </form>
    {% for table in tables %}
            {{ table|safe }}
    {% endfor %}
  </body>
</html>
The project tree:
├── script.py
├── templates
    └── upload.html
Dockerfile:
FROM python:3.7-slim-buster
WORKDIR /app
COPY requirements.txt ./
RUN apt-get update 
RUN pip install --no-cache-dir -r requirements.txt
RUN mkdir /templates
COPY script.py /app/
COPY ./templates/ /app/templates/
RUN dir
CMD [ "python", "script.py" ]
and I launch the docker image as
docker run -it --rm -p 5000:5000 online-app
The the logs are as follows:
* Serving Flask app "script" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 416-968-407
I go to the http://127.0.0.1:5000/ and the page is loading forever. What did I miss?
UPD:
Using
app.run(debug=True, host=0.0.0.0, port=5000)  # running the flask app
has logs like:
 * Running on http://172.17.0.2:5000/ (Press CTRL+C to quit)
But the link is dead as well
 
     
    