[英]No /var/run/docker.sock on OS X
I'm trying to use REST calls to access Docker information. 我正在尝试使用REST调用来访问Docker信息。 I tried this example I pulled off a web site: 我尝试了这个例子,我推出了一个网站:
echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
I got no errors but nothing happened. 我没有错,但什么也没发生。 I have docker images on my system (I can do 'docker images' and see a list). 我的系统上有docker图像(我可以做'docker images'并查看列表)。 I have no issues running command-line docker tools. 运行命令行docker工具时没有问题。
Looking at the file system, there is no /var/run/docker.sock on my system. 查看文件系统,我的系统上没有/var/run/docker.sock。
I'm using an out-of-the-box boot2docker installation on OS X. Docker info output is here: 我在OS X上使用开箱即用的boot2docker安装。Docker信息输出在这里:
bash-3.2$ docker info
Containers: 6
Images: 174
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Dirs: 186
Execution Driver: native-0.2
Kernel Version: 3.16.7-tinycore64
Operating System: Boot2Docker 1.3.2 (TCL 5.4); master : 495c19a - Mon Nov 24 20:40:58 UTC 2014
Debug mode (server): true
Debug mode (client): false
Fds: 11
Goroutines: 13
EventsListeners: 0
Init Path: /usr/local/bin/docker
What am I missing? 我错过了什么?
Docker runs on 64-bit linux kernels only. Docker仅在64位Linux内核上运行。 If you're using boot2docker, you're actually talking to an install of Docker inside a virtualbox VM. 如果您正在使用boot2docker,那么您实际上是在虚拟机VM中安装Docker。 The Docker client (on your Mac) is actually making REST calls over TLS to the Docker daemon inside the VM. Docker客户端(在Mac上)实际上通过TLS对VM内的Docker守护进程进行REST调用。
As your Docker daemon is already set up to do TLS, you don't need to use the nc
trick to talk to the socket, we can just use curl directly. 由于您的Docker守护程序已经设置为执行TLS,您不需要使用nc
技巧与套接字通信,我们可以直接使用curl。 Unfortunately, the version of curl installed on Macs doesn't support the certificate type used in boot2docker, so we have to create a new certificate first: 不幸的是,Mac上安装的curl版本不支持boot2docker中使用的证书类型,因此我们必须首先创建一个新证书:
$ cd ~/.boot2docker/certs/boot2docker-vm/
$ openssl pkcs12 -export -inkey key.pem \
-in cert.pem -name b2d-client-side \
-out b2d-client-side.p12 \
-password pass:tcuser
This should create the file b2d-client-side.p12
. 这应该创建文件b2d-client-side.p12
。 (I took these instructions from https://github.com/boot2docker/boot2docker/issues/573 ). (我从https://github.com/boot2docker/boot2docker/issues/573获取了这些说明)。 Now we can use curl: 现在我们可以使用curl:
$ curl \
--cacert ~/.boot2docker/certs/boot2docker-vm/ca.pem \
--cert ~/.boot2docker/certs/boot2docker-vm/b2d-client-side.p12:tcuser \
https://$(boot2docker ip):2376/images/json
[{"Created":1432076009,"Id":"b96d1548a24e2a089512da28da79ce70825f6d7f"....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.