背景:
安装nginx后, 指定了映射端口,而在浏览器中却始终无法访问,令人崩溃~!
原因:
The reason you’re having this, is because on Linux, the docker daemon (and your containers) run on the Linux machine itself, so “localhost” is also the host that the container is running on, and the ports are mapped to.
On Windows (and OS X), the docker daemon, and your containers cannot run natively, so only the docker client is running on your Windows machine, but the daemon (and your containers) run in a VirtualBox Virtual Machine, that runs Linux.
简而言之,docker映射的端口是虚拟机的端口,而不是windows的端口.
解决:
1.运行命令docker-machine ip default查看虚拟机的ip地址,默认为192.168.99.100
2.在浏览器中使用指定的ip地址和端口访问.