简体   繁体   English

OS X上没有/var/run/docker.sock

[英]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.

相关问题 Docker错误拨号unix /var/run/docker.sock:没有这样的文件或目录 - Docker error dial unix /var/run/docker.sock: no such file or directory Jenkins拨打Unix /var/run/docker.sock:连接:权限被MacOS拒绝 - Jenkins dial unix /var/run/docker.sock: connect: permission denied MacOS Jenkins/MacOS - 拨打 unix /var/run/docker.sock: connect:permission denied - Jenkins/ MacOS - dial unix /var/run/docker.sock: connect:permission denied 如何以非 root 用户身份从 docker 容器内部访问 /var/run/docker.sock? (MacOS 主机) - How to access /var/run/docker.sock from inside a docker container as a non-root user? (MacOS Host) macOS - docker:无法连接到 unix:///var/run/docker.sock 的 Docker 守护程序。 docker 守护程序是否正在运行? - macOS - docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Mac/OS X 上的 /var/lib/docker 在哪里 - Where is /var/lib/docker on Mac/OS X 在容器内 chowning 主机绑定的 `docker.sock` 会破坏主机 docker - chowning the host's bound `docker.sock` inside container breaks host docker 无法使用 boot2docker 在 os X 上运行 docker - Can't run docker on os X with boot2docker 为什么我被迫在 OS X 上使用 sudo 运行 docker? - Why am i forced to run docker with sudo on OS X? 使用 Ansible 在 OS X 上运行 docker 任务的问题 - problems using Ansible to run docker tasks on OS X
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM