简体   繁体   English

如何使用docker-machine为Docker获取HOST_IP?

[英]How I can I get HOST_IP for Docker using docker-machine?

I just got a new Mac. 我刚买了一台新Mac。 My old Mac had a shell script that included these lines: 我的旧Mac的shell脚本包含以下几行:

ACTIVE=`docker-machine active 2>/dev/null`
HOST_IP=`docker-machine ip $ACTIVE`

When I run this on the new machine it doesn't work. 当我在新计算机上运行此命令时,它不起作用。 Just running the docker-machine active command independently I get output like this: 只是独立运行docker-machine active命令,我得到这样的输出:

No active host found

I figured I try to create a default with docker-machine create default, but got this: 我想我试图用docker-machine create default创建一个默认值,但是得到了这个:

dial-http tcp 127.0.0.1:49719: unexpected EOF

I'm not sure what version of Docker my old Mac was running, but it was native. 我不确定我的旧Mac正在运行哪个版本的Docker,但它是本地的。 New Mac: 新Mac:

Client:
 Version:      17.06.1-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:53:38 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.06.1-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:54:55 2017
 OS/Arch:      linux/amd64
 Experimental: true

New versions of Docker for Mac no longer user VirtualBox and docker-machine. Mac的新版本Docker不再使用VirtualBox和docker-machine。 It's running on xhyve and you can run docker commands very similar to if you were running docker natively on a linux host. 它在xhyve上运行,您可以运行docker命令,就像您在Linux主机上本地运行docker一样。 There's still a VM under the covers (using moby), but your scripts shouldn't see that anymore. 幕后仍然有一个VM(使用Moby),但是您的脚本再也看不到了。 Anything you use to connect to published ports can now connect to localhost as if it is running directly on the Mac host. 现在,您用来连接已发布端口的所有内容都可以连接到localhost,就好像它直接在Mac主机上运行一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM