I am trying to run a flask application in a docker on windows, and python 3.7.
This is my flask application:
app.py:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
#some lines of code
return render_template('home.html', url=url, host='0.0.0.0')
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
Then I created a dockerfile.txt as a DockerFile and put the following contents inside:
FROM python:3.7
MAINTAINER <<Your Name>>
RUN apt-get update -y && \
apt-get install -y python3-pip python3-dev
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip3 install -t lib -r requirements.txt
COPY . /app
ENTRYPOINT [ "python3" ]
CMD [ "app.py" ]
Then I run the following comments in command prompt:
docker build -t flask-image:latest .
docker run -d -p 5000:5000 --name name-container1 flask-image
My problem is that after docker ps -a
I see container name-container1
is exited. But have no idea why???
This is output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d925f21f165c flask-image "python3 app.py" About a minute ago Exited (1) About a minute ago name-container1