"CURL: connection refused" when trying to curl localhost: 5000 to container flask

  curl, docker, dockerfile, flask, port

I have a problem executing the command curl localhost:5000, can someone give me some help?

[email protected]:~/latihan04$ sudo docker run -d -p 5000:5000 --name flask04 jesaya/flask-latihan04
14acc48334060ba79c9f3dd5eaafcc0ea0767d29c531eac0d48ae6649af54e2c
[email protected]:~/latihan04$ curl localhost:5000
curl: (7) Failed to connect to localhost port 5000: Connection refused
[email protected]:~/latihan04$

app.py script

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
        return 'Hey, we have Flask in a Docker container!'


    if __name__ == '__main__':
            app.run(debug=True, host='0.0.0.0')

requirements.txt

Flask==0.10.1

Dockerfile

FROM ubuntu:16.04
RUN mkdir /app
RUN apt-get update -y && 
        apt-get install python-pip python-dev -y

COPY ./requirements.txt /app
COPY . /app

WORKDIR /app
RUN pip install -r requirements.txt

ENTRYPOINT ["python"]
CMD ["app.py"]

Source: Docker Questions

LEAVE A COMMENT