适用于Mac VM IP的Docker [英] Docker for Mac VM IP

查看:133
本文介绍了适用于Mac VM IP的Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚迁移到使用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 at localhost.

这篇关于适用于Mac VM IP的Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆