Reputation: 723
I'm messing about with Docker (using Docker Toolbox for OSX) and can't seem to get my application to work. It's a simple flask application which looks like this:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello World!'
if __name__ == '__main__':
app.run()
Now my Dockerfile contains the following
FROM python:2.7.11-wheezy
ADD ./application/* /opt/local/application/
ADD ./project-requirements.txt /opt/local/application/requirements.txt
RUN pip install -r /opt/local/application/requirements.txt
CMD ["/usr/local/bin/python", "/opt/local/application/app.py"]
EXPOSE 5000
I build the container by running docker build -t python_app .
and subsequently boot the container by running docker -i -P python_app
and see that the application is booted inside the container, as the output of the command is * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
.
Now when I run docker ps
I can see the container is running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
448defb349ce python_app "/usr/local/bin/pytho" About a minute ago Up About a minute 0.0.0.0:32769->5000/tcp angry_jang
But when I try to curl the container, I get a connection refused error.
$ curl $(docker-machine ip default):32769
curl: (7) Failed to connect to 192.168.99.100 port 32769: Connection refused
I have no clue where I'm going wrong with this and any help is much appreciated!
Upvotes: 2
Views: 928
Reputation: 723
I found the issue, I had to change
app.run()
to
app.run(host='0.0.0.0')
in the app.py
file.
Upvotes: 4