适用于Mac VM IP的Docker [英] Docker for Mac VM IP
问题描述
我刚刚迁移到使用Mac的Docker,之前是使用Docker Toolbox和virtualbox for OSX的.
I just migrated to using Docker for Mac, from previously using Docker Toolbox with virtualbox for OSX.
我以前用$(docker-machine ip default)
获取机器IP地址.
I used to get the machine IP address with $(docker-machine ip default)
.
是否有可靠的方法来获取Hyperkit IP地址?
Is there a reliable way to get the Hyperkit IP address?
谢谢!
推荐答案
无需像使用docker-machine
那样直接使用xhyve VM的IP地址.所有端口映射都直接映射到localhost
.
There's no need for working with the xhyve VM's IP address directly like you would with docker-machine
. All port mappings are directly mapped to localhost
.
$ docker run -d -p 8080:80 nginx:latest
$ curl localhost:8080
另请参见官方文档:
当您使用
-p
参数运行容器时,例如:$ docker run -p 80:80 -d nginx
Docker for Mac将使容器端口在localhost
处可用.
When you run a container with the
-p
argument, for example:$ docker run -p 80:80 -d nginx
Docker for Mac will make the container port available atlocalhost
.
这篇关于适用于Mac VM IP的Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!