更新于2022年8月31日:
原始方法现在可能会导致Docker错误:
standard_init_linux.go:228: exec user process caused: no such file or directory
如果您使用系统包而不是从软件库直接下载,则问题得到解决。在Ubuntu的情况下:
RUN apt-get install tini
其余的部分相同:
RUN chmod +x /usr/bin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
刚好遇到了同样的问题。似乎你不能直接从容器中运行Jupyter。但是这个链接帮助了我。基本上你需要做以下几步:
- 在你的dockerfile中添加以下内容:
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", "--"]
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
这将在端口8888上启动容器内的Jupyter。因此,在docker-compose或docker run中不要忘记公开此端口。
这在我的本地docker上有效。我可以假设对于SSH docker,您需要在远程连接到本地主机期间转发8888端口。