Dash: Run in docker cannot connect

Created on 13 Apr 2018  ·  4Comments  ·  Source: plotly/dash

When i use docker to run the service, i got an error below, is anyone who met the issue?

local run is ok:

❯ python index.py
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 211-018-208
127.0.0.1 - - [13/Apr/2018 20:47:25] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:25] "GET /_dash-component-suites/dash_renderer/[email protected]?v=0.12.1 HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:25] "GET /_dash-component-suites/dash_renderer/[email protected]?v=0.12.1 HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:25] "GET /_dash-component-suites/dash_html_components/bundle.js?v=0.10.0 HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:25] "GET /_dash-component-suites/dash_core_components/plotly-1.35.2.min.js?v=0.22.1 HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:25] "GET /_dash-component-suites/dash_core_components/bundle.js?v=0.22.1 HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:25] "GET /_dash-component-suites/dash_renderer/bundle.js?v=0.12.1 HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:26] "GET /_dash-layout HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:26] "GET /_dash-dependencies HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:26] "POST /_dash-update-component HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:26] "POST /_dash-update-component HTTP/1.1" 200 -
127.0.0.1 - - [13/Apr/2018 20:47:26] "GET /favicon.ico HTTP/1.1" 200 -

My dockerfile is:

  1 FROM ********/python-3.6.3
  2
  3 RUN mkdir /visualization_test
  4 COPY . /visualization_test
  5
  6 WORKDIR /visualization_test
  7 RUN pip install \
  9         dash==0.21.0 \
 10         dash-renderer==0.12.1 \
 11         dash-html-components==0.10.0 \
 12         dash-core-components==0.22.1 \
 13         dash-table-experiments\
 14         plotly --upgrade
 15
 16 EXPOSE 8050                                                                                                                                                                                       
 17 CMD ["python", "index.py"]

and docker run is:

❯ docker run --rm -it -p 8050:8050 visual
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 192-469-391

but i got:

image

the status:

❯ docker ps
CONTAINER ID        IMAGE                                           COMMAND                  CREATED             STATUS              PORTS                      NAMES
98409d420605        visual                                          "python index.py"        5 minutes ago       Up 6 minutes        0.0.0.0:8050->8050/tcp     confident_lichterman

oh, i also add app.scripts.config.serve_locally=True in app.py which was mentioned in https://github.com/plotly/dash/issues/125#issuecomment-359667498

Most helpful comment

Are you running it with app.run_server(host='0.0.0.0', ...)?

All 4 comments

Are you running it with app.run_server(host='0.0.0.0', ...)?

i got that, many thanks...
@kfkelvinng

Are you running it with app.run_server(host='0.0.0.0', ...)?

why does this work but not any other host?

Are you running it with app.run_server(host='0.0.0.0', ...)?

why does this work but not any other host?

https://flask.palletsprojects.com/en/1.1.x/api/?highlight=external#flask.Flask.run

host – the hostname to listen on. Set this to '0.0.0.0' to have the server available externally as well. Defaults to '127.0.0.1' or the host in the SERVER_NAME config variable if present.

The path to call Flask.run from Dash as follow:
https://github.com/plotly/dash/blob/v1.15.0/dash/dash.py#L1471
https://github.com/plotly/dash/blob/v1.15.0/dash/dash.py#L1494
https://github.com/plotly/dash/blob/v1.15.0/dash/dash.py#L1632
https://github.com/plotly/dash/blob/v1.15.0/dash/dash.py#L273

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ninjakx picture ninjakx  ·  3Comments

mheydasch picture mheydasch  ·  3Comments

maartenbreddels picture maartenbreddels  ·  4Comments

gsimchoni picture gsimchoni  ·  3Comments

T4rk1n picture T4rk1n  ·  3Comments