无法访问 http://0.0.0.0:8000

问题描述

我正在遵循 https://fenics.readthedocs.io/projects/containers/en/latest/introduction.html 的指示。

我明白了:

fenics@af86d2c8af46:~$ cd ~/demo/python/documented/poisson
fenics@af86d2c8af46:~/demo/python/documented/poisson$     python3 demo_poisson.py
Calling FFC just-in-time (JIT) compiler,this may take some time.
Calling FFC just-in-time (JIT) compiler,this may take some time.
Solving linear variational problem.
To view figure,visit http://0.0.0.0:8000
Press Ctrl+C to stop WebAgg server

但我无法打开 http://0.0.0.0:8000(我尝试过 chrome、safari 和 firefox)。我也试过替换 0.0.0.0。使用我的 IP 地址或本地主机,但问题仍然存在。

编辑:我不确定这是否起作用,但是如果我尝试使用 http://0.0.0.0:8000 或 localhost:8000,我会立即收到错误消息,但是当我将 0.0.0.0 替换为我的 IP 地址时,我会明白“兄弟俩花了太长时间”。

解决方法

0.0.0.0 is not a real IP address。在这种情况下,它指定该服务可通过该机器拥有的任何 IPv4 地址访问。您可以通过 http://127.0.0.1:8000 连接到该服务。

您还需要将 docker 端口转发到主机:

docker run -p 8000:8000 -ti quay.io/fenicsproject/stable:latest