在Docker Toolbox上安装的Mac OSX上的Docker端口映射 [英] Port mapping in Docker on Mac OSX installed with Docker Toolbox
问题描述
我打开了Docker Quickstart Terminal,并运行了
docker运行hello-world
p>
然后我试过:
docker run -d -p 8080:80 nginx
我可以看到容器已添加。
当我浏览到$ $ c $时,容器ID只返回任何东西, c> localhost:8080 with chrome我没看到nginx的欢迎页面。我尝试运行几个不同的容器,这些容器应该可以提供流量,但是没有一个可以运行。现有的github问题和SO问题都似乎在谈论不再存在的东西 - 或者至少在Mac OSX上不是默认的。
localhost
不是您的码头运行的主机。您需要转到正在运行的docker守护程序的IP地址。
要找到您的docker机器的IP地址,请运行命令:
docker-machine ip default
其中默认值
是您的虚拟机的名称(如大多数安装的情况)。
如果该命令返回类似于 192.168.99.100
,那么你可以到达你正在运行的docker容器,它的外露端口如下所示: 192.168.99.100:8080
。
I installed Docker on a Mac using the Docker Toolbox.
I opened Docker Quickstart Terminal and ran
docker run hello-world
That works fine.
Then I tried:
docker run -d -p 8080:80 nginx
I can see that the container is added. docker log
with the container id returns nothing but I think that's normal?
When I browse to localhost:8080
with chrome I don't see the nginx welcome page. I've tried running a few different containers that are supposed to serve traffic but none of them have worked. The existing github issues and SO questions all seem to be talking about things which don't exist anymore - or at least are not default on Mac OSX.
localhost
is not the host where your docker is running. You need to go to the IP address of your running docker daemon.
To find the IP address for your docker machine, run the command:
docker-machine ip default
where default
is the name of your VM (as is the case I think for most installations).
If that command returned something like 192.168.99.100
, then you can reach your running docker container and it's exposed port like this: 192.168.99.100:8080
.
这篇关于在Docker Toolbox上安装的Mac OSX上的Docker端口映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!