我已经创建了一个码头文件,通过遵循https://www.youtube.com/watch?v=QkOKkrKqI-k,码头构建非常好,并运行jupyter实验室。此外,我还可以运行一个简单的破折号应用程序。
import plotly.express as px
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
# Load Data
df = px.data.tips()
# Build App
app = JupyterDash(__name__)
app.layout = html.Div([
html.H1("JupyterDash Demo"),
dcc.Graph(id='graph'),
html.Label([
"colorscale",
dcc.Dropdown(
id='colorscale-dropdown', clearable=False,
value='plasma', options=[
{'label': c, 'value': c}
for c in px.colors.named_colorscales()
])
]),
])
# Define callback to update graph
@app.callback(
Output('graph', 'figure'),
[Input("colorscale-dropdown", "value")]
)
def update_figure(colorscale):
return px.scatter(
df, x="total_bill", y="tip", color="size",
color_continuous_scale=colorscale,
render_mode="webgl", title="Tips"
)
# Run app and display result inline in the notebook
app.run_server(mode='inline') --> This doesn't work
app.run_server(mode='jupyterlab') --> This doesn't work
# app.run_server(mode='external') --> This doesn't work在dockerfile中,我公开了端口8888和8050。在构建了docker文件之后,我使用端口命令分别将端口命令公开到8888和8050,如下所示。
docker run -it -p 8888:8888 -p 8050:8050 <image-name>
然而,当我在external mode上运行我的dash应用程序时:然后它显示给我

当我试图连接那个URL时,我发现它不起作用。
有人知道怎么解决这个问题吗?我知道如何使用烧瓶打开应用程序,但我想遵循传统的方式,在视频中建议。
Dockerfile:
FROM python:3.8.0
RUN git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it && \
bash ~/.bash_it/install.sh --silent
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get upgrade -y && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip && \
pip install --upgrade \
numpy \
pandas \
dash \
Jupyterlab \
ipywidgets \
jupyterlab-git \
jupyter-dash
RUN jupyter lab build
# RUN pip install --upgrade pip && \
# pip install --upgrade \
# jupyterlab "pywidgets>=7.5"
RUN jupyter labextension install \
jupyterlab-plotly@4.14.3 \
@jupyter-widgets/jupyterlab-manager \
@jupyterlab/git
COPY entrypoint.sh /usr/local/bin/
RUN chmod 755 /usr/local/bin/entrypoint.sh
COPY config/ /root/.jupyter/
EXPOSE 8888 8050
VOLUME /notebooks
WORKDIR /notebooks
# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD jupyter lab --ip=* --port=8888 --allow-root发布于 2021-11-26 17:20:13
我不知道我的答案是否正确,但我成功了。如果有人有更好的解决方案,请张贴在这里。
之后,
docker run -it -p 8888:8888 -p 8050:8050 <ImageName>
我所做的唯一更改是(app.run_server中的主机名),所以我的主命令如下所示:
app.run_server(mode='inline', host="0.0.0.0", port=8050, dev_tools_ui=True)对inline、external和jupyterlab都适用。
https://stackoverflow.com/questions/70118476
复制相似问题