尝试通过 Docker 运行 TensorFlow 时无法访问 Jupyter notebook

Having difficulty accessing the Jupyter notebook when trying to run TensorFlow through Docker

我的问题:

这里是 ML 领域的新手。我目前正在尝试通过 docker 设置 tensorflow,但是一旦 tensorflow 似乎 运行ning,我在访问 jupyter notebook 时遇到了一些麻烦。为了将来参考,我正在使用 windows 10、powershell、python 2.7 和 oracle virtualbox (v.5.0.16)。

我非常有信心 docker 工作正常,因为我完成了他们的设置教程 ("Using docker from Powershell"),没有任何问题——我能够 运行 hello world 示例那里就好了。我还能够使用命令

成功 运行 一个 ubuntu 终端
docker run -it ubuntu bash

然后我按照tensorflow docker installation instructions,一切似乎都很正常——我输入了tensorflow的docker 运行命令:

docker run -it b.gcr.io/tensorflow/tensorflow

得到这个输出:

[I 19:33:16.330 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 19:33:16.360 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[W 19:33:16.360 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.
[I 19:33:16.365 NotebookApp] Serving notebooks from local directory: /notebooks
[I 19:33:16.365 NotebookApp] 0 active kernels
[I 19:33:16.365 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/
[I 19:33:16.366 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

但是,当我尝试访问 localhost:8888 上的 jupyter notebook 时,chrome 说无法在几秒钟内访问该站点并且服务器拒绝连接。

我尝试过的解决方案:

我感谢提供的所有帮助。如果我所说的任何内容含糊不清,或者我是否可以提供有关我尝试过的内容的更多详细信息,请告诉我。非常感谢你提前。

尝试将 -p 8888:888 添加到 docker 运行 命令。

docker run -p 8888:8888 -it b.gcr.io/tensorflow/tensorflow

找到解决方案in this tensorflow issue, in a comment by HWiese1980

Since Docker usually needs to have the same operating system on the Docker host system as it's in the Docker container (well, parts that is) you need a Linux VM to run a Docker container that is based on Linux under Windows. Docker itself opens port 8888 between the VM and the container. You have to explicitly tell it to forward the port from the outside of the VM to the open Docker container port by using said parameter -p 8888:8888.

对于 ubuntu 14.04 我不得不使用下面的命令来指定 '/bin/bash' 以便它进入交互式控制台。

docker run -it gcr.io/tensorflow/tensorflow /bin/bash