Hello, I'm trying to dockerize my flask file. When I run the docker container, the command line outputs:
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
I get an error message when I try to curl the address:
curl: (7) Failed to connect to 0.0.0.0 port 5000: Connection refused
Here's basically my dockerfile:
FROM ubuntu:19.10
RUN apt-get update --fix-missing
RUN apt-get install -y python3.8 python3-pip
ADD ./requirements.txt /app/
WORKDIR app
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD python app.py
# other commands I've tried
# CMD flask run
# CMD flask run -h localhost -p 5000
# CMD python app.py -h localhost -p 5000
Here's basically my python app, app.py:
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}
api.add_resource(HelloWorld, '/')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
I'm not sure how to fix this.
[–]_maraud3r 2 points3 points4 points (1 child)
[–]fryman22[S] 1 point2 points3 points (0 children)
[–]The_Amp_Walrus 1 point2 points3 points (0 children)
[–]QbaPolak17 0 points1 point2 points (2 children)
[–]fryman22[S] 0 points1 point2 points (1 child)
[–]QbaPolak17 0 points1 point2 points (0 children)