[英]Connection refused for Docker application on OSX
I'm messing about with Docker (using Docker Toolbox for OSX) and can't seem to get my application to work. 我搞砸了Docker(使用OSX的Docker Toolbox),似乎无法使我的应用程序正常工作。 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 现在我的Dockerfile包含以下内容
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 .
我通过运行
docker build -t python_app .
构建容器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)
. 然后通过运行
docker -i -P python_app
引导容器,并看到应用程序已在容器内部引导,因为命令的输出为* 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 现在,当我运行
docker ps
我可以看到容器正在运行
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! 我不知道我要怎么做,任何帮助都将不胜感激!
I found the issue, I had to change 我发现了问题,我不得不改变
app.run()
to 至
app.run(host='0.0.0.0')
in the app.py
file. 在
app.py
文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.