首页 > 解决方案 > 暴露 jupyter 容器的备用端口不起作用

问题描述

我正在尝试在端口 10000 上运行 r-noteb ook ( https://hub.docker.com/r/jupyter/r-notebook/ ) 的 jupyter 容器。

使用命令:

docker run -p 10000:10000 jupyter/r-notebook

这是输出:

Executing the command: jupyter notebook
[I 14:14:28.508 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[I 14:14:28.954 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
[I 14:14:28.955 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 14:14:28.959 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 14:14:28.959 NotebookApp] The Jupyter Notebook is running at:
[I 14:14:28.959 NotebookApp] http://(165e94335316 or 127.0.0.1):8888/?token=45a5ff037dfa5dfd8aca69ae8489b4bb814009a9b7f6abf6
[I 14:14:28.959 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:14:28.961 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://(165e94335316 or 127.0.0.1):8888/?token=45a5ff037dfa5dfd8aca69ae8489b4bb814009a9b7f6abf6

从输出:

to login with a token:
            http://(165e94335316 or 127.0.0.1):8888/?token=45a5ff037dfa5dfd8aca69ae8489b4bb814009a9b7f6abf6

可以看到端口8888被暴露而不是10000

我是否正确映射了端口?

在浏览器上访问http://localhost:10000/http://127.0.0.1:10000/http://165e94335316:10000/返回“找不到页面”错误。

标签: rdockerjupyter-notebook

解决方案


使用docker run -p 10000:8888 jupyter/r-notebook并访问http://localhost:10000运行它。右侧端口应该是8888因为所有 Jupyter 笔记本容器都暴露在端口上,如此8888所示。

-p 10000:8888,8888是 jupyter notebook 在容器内运行的端口。10000是在容器中运行的笔记本暴露给主机的端口。

另一个提示:要从http://localhost:8888访问 Jupyter notebook ,请更改100008888.

docker run -p 8888:8888 jupyter/r-notebook

推荐阅读