Reputation: 11
I am following this tutorial: https://www.geeksforgeeks.org/dockerize-your-flask-app/
Everything works well until I get to this step: "Build the Docker image Make sure you are in root directory of the project and run the following command."
To get into the root directory, I enter sudo su
, then I run the following command as seen in the tutorial:
sudo docker build --tag flask-docker-demo-app .
When I run the above, I get this response:
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?
To carry out these commands, I am using the Ubuntu 18.04 LTS App for windows. I have the Docker Desktop downloaded also.
Additionally, I don't think this has any impact, but I have a different demo.py than the tutorial provides. Here is my 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)```
Upvotes: 1
Views: 81
Reputation: 8945
You should place your user in the docker
group so that you do not have to issue sudo
to use Docker. (In fact, of course you should never do that!)
And then ... "well, is the Docker daemon running?" Looks like you might need to (re-)install it.
Upvotes: 0
Reputation: 173
Running the sudo su
before running your other command is obsolete as it is running as superuser by adding the prefix sudo
.
"root directory" doesn't mean your root-user directory but the root-directory of your project, where your Dockerfile is stored. You have to navigate to that directory before running the docker build
command.
Upvotes: 2