Greg
Greg

Reputation: 11512

No /var/run/docker.sock on OS X

I'm trying to use REST calls to access Docker information. 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). I have no issues running command-line docker tools.

Looking at the file system, there is no /var/run/docker.sock on my system.

I'm using an out-of-the-box boot2docker installation on OS X. Docker info output is here:

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?

Upvotes: 7

Views: 5583

Answers (1)

Adrian Mouat
Adrian Mouat

Reputation: 46480

Docker runs on 64-bit linux kernels only. If you're using boot2docker, you're actually talking to an install of Docker inside a virtualbox VM. The Docker client (on your Mac) is actually making REST calls over TLS to the Docker daemon inside the VM.

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. 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:

$ 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. (I took these instructions from https://github.com/boot2docker/boot2docker/issues/573). Now we can use 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"....

Upvotes: 2

Related Questions