如何在Docker容器中打开jupyter nookbooks?

运行docker-compose ps时,我有以下容器:

  Name Command State Ports --------------------------------------------------------------------------------- rainmaker_db_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp rainmaker_python_1 python -u /app/run.py Up 0.0.0.0:5000->5000/tcp 

我想在容器rainmaker_python_1内运行jupyther,所以我正在运行以下命令:

 docker-compose exec python jupyter notebook --allow-root 

然后我得到以下输出:

 [I 23:03:19.168 NotebookApp] Serving notebooks from local directory: /app [I 23:03:19.168 NotebookApp] 0 active kernels [I 23:03:19.168 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=35ff0fa9ec171204dbd7542d9c493c760055de24e1b7af18 [I 23:03:19.168 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [W 23:03:19.169 NotebookApp] No web browser found: could not locate runnable browser. [C 23:03:19.169 NotebookApp] Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8888/?token=35ff0fa9ec171204dbd7542d9c493c760055de24e1b7af18 

但是,如果我复制并粘贴链接http://localhost:8888/?token=35ff0fa9ec171204dbd7542d9c493c760055de24e1b7af18我得到该网站无法联系。 然后我试着:

 http://localhost:5000/?token=35ff0fa9ec171204dbd7542d9c493c760055de24e1b7af18 

但是我得到以下几点:

在这里输入图像说明

我想能够执行jupyter笔记本,所以请我希望有人能帮助我。 我几乎没有使用Docker的经验。

Jupyter笔记本的默认端口号似乎是8888.当Docker容器启动Jupyter时,您可以在控制台输出中看到这一点。

或者在Docker撰写文件中更改端口映射(如下所示),或者查看是否有可在Docker撰写文件中设置的环境variables,以使Docker / Jupyter在您打开的端口上运行(5000 )。

下面,Docker组合部分在端口8888上build立一个Node服务器(谢谢copypasta),但是应该提供足够的例子来改变你的) – 真正唯一重要的是端口线。

 version: '2' services: nodejs: build: context: . dockerfile: DockerFile ports: - "8888:8888"