问题描述
所以我使用 Docker Toolbox 是因为我的机器上没有 Hyper-V,因为它不是 Windows 10 专业版.一切似乎都正常,但是当我尝试使用浏览器 0.0.0.0:80
时,它总是返回:无法访问此站点
So I'm using Docker Toolbox because I don't have Hyper-V on my machine since it's not Windows 10 pro. Everything seems to work fine, but when I try to go on my browser 0.0.0.0:80
it always returns me: This site can’t be reached
但是当我运行命令时:docker container ps
我得到以下信息:0.0.0.0:80->80/tcp
意味着这个地址应该可以工作.我搜索了 stackoverflow 和 github 问题.现在我被困住了.
But when I run the command: docker container ps
I get the following: 0.0.0.0:80->80/tcp
meaning that this address should work. I searched across stackoverflow and github issues. Now I'm stuck.
我错过了什么吗?
谢谢,标记
使用 docker-machine ip default
返回我 192.168.99.100
.我在端口 80 上运行它.除了地址变成容器 ID 之外,我仍然得到相同的结果:https://fd677edg12
Using docker-machine ip default
returns me 192.168.99.100
. I run that on port 80. I still get the same result except that the address becomes the container id: https://fd677edg12
我在 cmd 上运行该命令以查找我的 ipv4:cmd/k ipconfig/all
.将结果与端口放在一起,它返回相同的内容:https://fd677edg12
I run that command on cmd to find my ipv4: cmd /k ipconfig /all
. Put the result with the port and it returns the same thing: https://fd677edg12
推荐答案
Docker Toolbox 没有 Docker for Windows 那么多的便利,但您使用它是正确的,因为您使用的是家庭版.
Docker Toolbox doesn't get as many conveniences as Docker for Windows, but you're correct in using it since you're on Home edition.
在 Toolbox 中,什么都不是 localhost
,默认是 192.168.99.100
,因为它在 VirtualBox 中运行 Linux VM.
In Toolbox, nothing will be localhost
, and will be 192.168.99.100
by default, since it's running a Linux VM in VirtualBox.
所以如果你运行 docker run -p 80:80 nginx
(注意我必须为 192.168.99.100
发布一个端口来监听那个端口)
(notice I had to publish a port for 192.168.99.100
to listen on that port)
然后转到 http://192.168.99.100
应该可以.
Then going to http://192.168.99.100
should work.
这篇关于Docker 工具箱 - 本地主机不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!