【发布时间】:2020-03-18 14:57:50
【问题描述】:
我正在关注本教程:https://www.geeksforgeeks.org/dockerize-your-flask-app/
在我执行此步骤之前一切正常: "构建 Docker 镜像 确保您位于项目的根目录并运行以下命令。”
要进入根目录,我输入sudo su,然后按照教程中所示运行以下命令:
sudo docker build --tag flask-docker-demo-app .
当我运行上面的,我得到这个响应:
ERRO[0000] failed to dial gRPC: cannot connect to the Docker daemon. Is docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: no such file or directory. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
为了执行这些命令,我使用的是适用于 Windows 的 Ubuntu 18.04 LTS 应用程序。我也下载了 Docker Desktop。
另外,我不认为这有任何影响,但我的 demo.py 与教程提供的不同。这是我的 demo.py:
from flask import Flask
server = Flask(__name__)
@server.route('/')
# ‘/’ URL is bound with hello_world() function.
def hello_world():
return 'Hello World'
import sys
print(sys.version)
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, server = server, routes_pathname_prefix = '/dash/', external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''
Dash: A web application framework for Python.
'''),
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 22], 'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)```
【问题讨论】:
标签: python windows docker ubuntu flask