运行 docker 图像中的 Jupyter 笔记本 Google 云

Running Jupyter notebook in docker image on Google Cloud

我是 运行 Ubuntu 16.04 VM Google Compute Engine。我创建了一个静态 IP 地址 <my_static_ip_address> 并且我的防火墙设置允许 tcp:80-8888.

我用

在 docker 图像中启动了 Jupyter 服务器

jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root

得到这个URL

http://0.0.0.0:8888/?token=8b26c453d278eae1da71b80f26a4ef8ea06734e5c636d897

我无法使用 http://<my_static_ip_address>:8888 从外部浏览器访问 我错过了什么?

I started the Jupyter server within the docker image with

您 运行 docker 命令是什么?这里的一个常见问题是不将主机端口映射到容器端口。

例如,如果您这样做:

docker run -p 8888 jupyter/notebook

然后docker会分配一个运行dom主机端口映射到容器中的8888端口。在这种情况下,您可以看到 运行 docker ps 映射了哪个端口。不过,该端口将比 8888 高得多,因此您将无法访问 jupyter,因为您的防火墙会阻止流量。

您可能想要做的是继续映射主机端口,如下所示:

docker run -p 8888:8888 jupyter/notebook

这应该将任何到达 GCE 主机端口 8888 的流量映射到您的 jupyter 容器中的端口 8888。