jupyter-dash icon indicating copy to clipboard operation
jupyter-dash copied to clipboard

jupyter-dash in a container

Open IvanNardini opened this issue 5 years ago • 3 comments

Hi,

I'm trying to prototype a plain-vanilla frontend in Dash for testing my model scoring in a jupyter docker container.

Below my code


from jupyter_dash import JupyterDash
import dash
import dash_core_components as component
import dash_html_components as html
app = JupyterDash(__name__)
app.layout = html.Div(children=[
    html.H1(children='Shopping App'),
    html.Div(children= 'A Scoring Interactive Web Service for testing')
])

app.run_server(mode="jupyterlab", host='172.23.0.6', port='8050', debug=True)

Everything starts fine but I get a page with this error

172.23.0.6 took too long to respond.

Any suggestion?

Thanks

IvanNardini avatar Jun 01 '20 12:06 IvanNardini

I was able to run your example sucessfully by setting debug=False ! (I, of course, substituted my own host IP)

BTW I stumbled on the solution because I was getting ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it when running the more complex getting_started sample app (with all three ouput modes)! I used your minimal example to troubleshoot and subsequently fixed my error (thank you!)

Hopefully this suggestion will help.

msbuckas avatar Jun 07 '20 17:06 msbuckas

I have JupyterHub running in a docker container that I started with docker run -it -p 10.92.39.100:8888:8000 --name jupyter jupyter

The IP of the host is 10.92.39.100 and I am able to access JupyterHub with http;//10.92.39.100:8888

The IP inside the container is 172.17.0.4

=> Do I need to map an extra port for jupyter-dash, e.g. 8050 or is it possible to access the app over the already mapped port? => What are the options for app.run_server that I should use?

Edit If I use docker run -it -p 10.92.39.100:8888:8000 -p 10.92.39.100:8050:8050 --name jupyter jupyter and

app.run_server(
    host='172.17.0.4',  # IP inside the docker container
    port=8050,  # mapped to http://tatooine:8050
    dev_tools_ui=True,
    debug=True,
    dev_tools_hot_reload=True,
    threaded=True
)

I am able to run the dash app. However, the shown link Dash app running on http://172.17.0.4:8050/ can not be used to open the app, because the internal IP 172.17.0.4 is not known outside the container.

The mode "inline" does not work for the same reason.

My workaround is to add an extra cell in Jupyterlab, showing the mapped address:

from IPython.display import IFrame
IFrame(src="http://10.92.39.100:8050", width='100%', height='500px')

=> Would be great if I could pass two IPs to jupyter-dash: one for server and one for the target link/inline mode.

stefaneidelloth avatar Jan 12 '21 13:01 stefaneidelloth

I know this was a while back, and not sure when it was added -- but now you should be able to specify the URL to load from in your create call like:

app = JupyterDash(__name__, server_url='http://10.92.39.100:8888')

and then when running still use:

app.run_server(host='172.17.0.4') #bind to one interface app.run_server(host='0.0.0.0') #bind to all interfaces

So it runs vs gets loaded at the correct different locations.

wiretail avatar Mar 07 '23 02:03 wiretail