[英]VSCode: How to run a Jupyter notebook in a docker container, over a remote server?
I can use the docker extension, and right click 'attach shell' to a running container.我可以使用 docker 扩展,然后右键单击“附加外壳”到正在运行的容器。 However, my Jupyter notebooks is not running in that container.但是,我的 Jupyter notebooks 并未在该容器中运行。
I tried googling how to run a jupyter notebook in a docker container, but I didn't get any results.我尝试用谷歌搜索如何在 docker 容器中运行 jupyter notebook,但没有得到任何结果。
If it makes a difference, I am trying to run my notebook in a docker container on a remote server (using VS Code remote ssh to log in)如果它有所作为,我正在尝试在远程服务器上的 docker 容器中运行我的笔记本(使用 VS Code 远程 ssh 登录)
Edit:编辑:
I also tried running我也试过跑步
!docker exec -ti {container name} bash
In jupyter, but that cell just hangs.在 jupyter 中,但那个单元格只是挂起。 When I stop the cell, the notebook still does not run in the container.当我停止单元格时,笔记本仍然没有在容器中运行。
Update 31.08.2022: The original approach now may cause Docker error: 2022 年 8 月 31 日更新:原来的方法现在可能会导致 Docker 错误:
standard_init_linux.go:228: exec user process caused: no such file or directory
Which is fixed if you're using system package instead of raw download from repo.如果您使用系统 package 而不是从 repo 原始下载,则该问题已修复。 In case of Ubuntu:如果是 Ubuntu:
RUN apt-get install tini
the rest is the same: rest 是相同的:
RUN chmod +x /usr/bin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
Just came to the same problem.刚遇到同样的问题。 It appeared that you cannot run Jupyter from a container out of the box.看来您无法从开箱即用的容器中运行 Jupyter。 But this link helped me.但是这个链接帮助了我。 Basically what you need is:基本上你需要的是:
# 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", "--"]
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
This will start jupyter inside a container on port 8888. So don't forget to expose this port in your docker-compose or docker run.这将在端口 8888 上的容器内启动 jupyter。所以不要忘记在 docker-compose 或 docker 运行中公开此端口。
This worked for me in my local docker. I can assume that for SSH docker you need to forward 8888 port during you SSH connection from remote to your local host.这在我的本地 docker 中对我有用。我可以假设对于 SSH docker,您需要在 SSH 从远程连接到本地主机期间转发 8888 端口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.