我正在关注this tutorial使用docker镜像,我正处于运行示例泊坞窗图像的阶段,如下所示:
docker run -p 4000:80 friendlyhello
在命令行上似乎没问题:
>docker run -p 4000:80 friendlyhello
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
但是当我尝试在网络浏览器上打开页面http://localhost:4000
时,它似乎无法连接(Safari和Firefox)。在Firefox上,错误消息是
Unable to connect
Firefox can't establish a connection to the server at localhost:4000.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer's network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
我还检查了文件/etc/hosts
,它包含以下条目
127.0.0.1 localhost
那可能是什么问题?
我找到this solution并尝试了以下命令:
docker run -p 127.0.0.1:4000:80 friendlyhello
仍然会导致同样的问题。我也试过打开
`http://localhost:80`
再次没有成功。