[英]Connect to jupyter notebook running in docker on a remote server
I have problems establishing a connection from my local machine to the jupyter notebook instance i have running on my remote server in a docker container. 我在从本地计算机到已在docker容器中的远程服务器上运行的jupyter笔记本实例建立连接时遇到问题。
What i did so far: 我到目前为止所做的:
I connect to the remote server with ssh username@remoteHostIp
我使用ssh username@remoteHostIp
连接到远程服务器
I run docker container ls
to make sure my container is not already running 我运行docker container ls
以确保我的容器尚未运行
Now I start my container with docker run -it -p 8888:8888 -p 6006:6006 -v ~/:/host waleedka/modern-deep-learning
现在我用docker run -it -p 8888:8888 -p 6006:6006 -v ~/:/host waleedka/modern-deep-learning
启动容器
Im now using the terminal in my container and start a browser-less jupyter notebook instance 我现在在容器中使用终端并启动无浏览器的Jupyter Notebook实例
jupyter notebook --no-browser --port=8889 --allow-root
It starts successfully: 它成功启动:
The Jupyter Notebook is running at:
[I 11:14:51.979 NotebookApp] system]:8889/
Now i start another shell on my local computer and create a ssh tunnel: 现在,我在本地计算机上启动另一个shell并创建ssh隧道:
ssh -N -f -L localhost:8888:localhost:8889 username@ remote_host_name
My shell returns the following after some seconds: 几秒钟后,我的shell返回以下内容:
channel 2: open failed: connect failed: Connection refused
channel 2: open failed: connect failed: Connection refused
channel 2: open failed: connect failed: Connection refused
Iam unable to access the jupyter notebook with localhost:8888/ or localhost:8889/ 我无法使用localhost:8888 /或localhost:8889 /访问jupyter笔记本
When i run jupyter notebook on the remote server outside of the docker container and create the ssh tunnel everything works fine. 当我在docker容器之外的远程服务器上运行jupyter notebook并创建ssh隧道时,一切正常。
Some additional information: remote server: Distributor ID: Ubuntu Description: Ubuntu 16.04.3 LTS Release: 16.04 Codename: xenial 一些其他信息:远程服务器:分发服务器ID:Ubuntu说明:Ubuntu 16.04.3 LTS版本:16.04代号:xenial
My local machine is running on osx moave 我的本地计算机在osx moave上运行
I solved the question myself by connecting to the remove server and checking for the docker container ip adress: docker inspect <container_name>
. 我通过连接到删除服务器并检查docker容器ip地址解决了自己的问题: docker inspect <container_name>
。 I used that ip adress then to create the ssh tunnel: 我用那个ip地址来创建ssh隧道:
ssh -N -f -L localhost:8889:dockerContainerIpAdress:8889 username@ remote_host_name
now i am able to connect to the jupyter notebook in my local browser with localhost:8889 现在我可以使用localhost:8889在本地浏览器中连接到jupyter笔记本
First you should connect to the remote server with 首先,您应该使用以下命令连接到远程服务器
ssh username@remoteHostIp
After connecting to it you should run docker container using 连接到它后,您应该使用
docker run -it -p 8080:8888 -p 6006:6006 -v ~/:/host waleedka/modern-deep-learning
i am considering here port 8888 is of jupyter notebook port and 8080 is of remote server port 我在这里考虑端口8888是jupyter笔记本端口,而8080是远程服务器端口
Now Open a new terminal window on your local machine, SSH into the remote machine again using the following options to setup port forwarding. 现在,在本地计算机上打开一个新的终端窗口,使用以下选项再次SSH到远程计算机以设置端口转发。
ssh -N -L localhost:8000:localhost:8080 username@remoteHostIp
i am considering here port 8000 is of my local machine port and 8080 as i said above is of remote server port already 我在这里考虑端口8000是我的本地计算机端口,而8080是我上面所说的已经是远程服务器端口
Now Access the remote jupyter server via your local browser. 现在,通过本地浏览器访问远程jupyter服务器。 Open your browser and go to: 打开浏览器,然后转到:
localhost:8000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.