【发布时间】:2018-11-12 22:31:45
【问题描述】:
我正在尝试基于 python 3 在 Docker 中运行 jupyter notebook。笔记本启动但将容器 ID 显示为 ip。如果我在打开链接后在浏览器中将其更改为“localhost:”,它确实有效。
如何使其正常工作并在 url 中显示 localhost:? /操作系统:Ubuntu 18.04/
编辑:我已经尝试过jupyter/minimal-notebook,它可以工作,显示 localhost,但它基于 ubuntu 18.04,它与我以后想在笔记本中使用的某些包不兼容。
Dockerfile:
FROM python:3
RUN apt-get -y update \
&& apt-get upgrade -y \
&& apt-get install -y \
curl \
vim \
xterm
RUN pip install --upgrade pip
RUN pip install --no-cache-dir jupyter numpy matplotlib
# Add Tini. Tini operates as a process subreaper for jupyter. This prevents
# kernel crashes.
ENV TINI_VERSION v0.6.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN chmod +x /usr/bin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]
EXPOSE 8888
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
编译后运行
docker run --rm -it -p 8888:8888 -v "$PWD":/home/work e4b37115446d
输出:
[I 11:48:12.580 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 11:48:12.826 NotebookApp] Serving notebooks from local directory: /
[I 11:48:12.826 NotebookApp] 0 active kernels
[I 11:48:12.826 NotebookApp] The Jupyter Notebook is running at:
[I 11:48:12.826 NotebookApp] http://3b906c2d97f3:8888/?token=06d43a78966a7b7e5fd04318183fa3e7af5bca7542477d31
[I 11:48:12.826 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:48:12.827 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time, to login with a token:
http://3b906c2d97f3:8888/?token=06d43a78966a7b7e5fd04318183fa3e7af5bca7542477d31&token=06d43a78966a7b7e5fd04318183fa3e7af5bca7542477d31
【问题讨论】:
-
我对 docker 没有太多经验,但是你应该跟进的错误不是明确的吗?你这样做了吗?
-
谢谢,现在用我尝试过的方法编辑了问题
标签: python docker jupyter-notebook jupyter