[英]How to connect google colab with localhost running docker image?
Errors while connecting with localhost link连接本地主机链接时出错
I am trying to run meilisearch in colab.我正在尝试在 colab 中运行 meilisearch。 I run meiliSearch in docker and I have a localhost link http://localhost:7700/ .我在 docker 运行 meiliSearch,我有一个本地主机链接http://localhost:7700/ 。 I have tried both http://localhost:7700/ as well as http://192.168.43.57:7700 .我已经尝试了http://localhost:7700/以及http://192.168.43.57:7700 。 But I am getting error.但我收到错误。 Although I can connect with my local jupyter notebook.虽然我可以连接到我本地的 jupyter notebook。 Any solution?任何解决方案?
I can't see the full screen but most likely the error in colab is because it is hosted on remote server by Google research where as the http://localhost:7700/ is on your local system.我看不到全屏,但 colab 中的错误很可能是因为它由 Google 研究托管在远程服务器上,因为 http://localhost:7700/ 在您的本地系统上。
You can't connect them using http://localhost:7700/.您无法使用 http://localhost:7700/ 连接它们。 And if you have also used your machines ip address, that is http://192.168.43.57:7700 and can't connect then did you first expose your port number 7700 to internet?如果您还使用过您的机器 ip 地址,即http://192.168.43.57:7700并且无法连接,那么您是否首先将端口号 7700 暴露给互联网?
You will need to expose your local machine and some ports(7700) using different services which provide the required.您将需要使用提供所需的不同服务来公开您的本地计算机和一些端口(7700)。
You can read the following article on how to setup tunneling service or ssh to expose the local development on internet.您可以阅读以下有关如何设置隧道服务或 ssh 的文章以在 Internet 上公开本地开发。
Medium Article on How to expose a local development server to the Internet 关于如何将本地开发服务器公开到 Internet 的中型文章
Or use this directly.或者直接使用这个。 Use local tunnel使用本地隧道
Please Follow below steps to connect docker image as a local runtime for Google-colab:请按照以下步骤将 docker 图像连接为 Google-colab 的本地运行时:
# Jupyter data science image including all packages, you may change the image as per your requirements FROM jupyter/datascience-notebook:latest # Colab step 1 RUN pip install jupyter_http_over_ws \ && jupyter serverextension enable --py jupyter_http_over_ws # Expose the port for host.network EXPOSE 8888 # Colab step 2 CMD ["jupyter","notebook","--NotebookApp.allow_origin='https://colab.research.google.com'","--allow-root","--port","8888","--NotebookApp.port_retries=0","--ip","0.0.0.0"]
docker build -t colab-runtime.
An Image colab-runtime:latest will be created.将创建一个图像colab-runtime:latest 。
Fire the command in terminal to run image as a container在终端中触发命令以将图像作为容器运行
Note:- Replace {your_host_path} with your host system path.注意:- 将 {your_host_path} 替换为您的主机系统路径。 eg /home/mujassim/work:/home/jovyan/work例如/home/mujassim/work:/home/jovyan/work
docker run -it -p 8888:8888 -v {your_host_path}:/home/jovyan/work colab-runtime:latest
After Running the above command, A URL is provided by the container in the logs.运行上述命令后,容器在日志中提供了一个 URL。
Paste that URL in colab runtime by replacing only 127.0.0.1 or container_id with localhost通过仅将127.0.0.1或container_id替换为localhost ,将 URL 粘贴到 colab 运行时
If you dont want to run step no.如果您不想运行步骤号。 3 again and again to start the jupyter server then follow the commands listed below: 3 一次又一次地启动 jupyter 服务器,然后按照下面列出的命令进行操作:
Note: You have to provide new URL each time in google colab.注意:您必须每次在 google colab 中提供新的 URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.