API via socket returns 'page not found'

Greetings,

I have dockerd running and exposing the api as a socket:

Nov 11 16:01:26 luna dockerd[10637]: time="2016-11-11T16:01:26.079879614-05:00" level=info msg="API listen on /run/docker.sock"

But a curl to the api returns page not found:

curl --unix-socket /run/docker.sock http://info
{"message":"page not found"}

What have I done wrong?

1 Like

Nothing; the error message you quote exactly matches the sample error at https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/. Try making a more involved API call.

(There are Docker libraries for many popular programming languages that know how to natively talk to the socket, though you may need to explicitly set an environment variable DOCKER_HOST=unix:///run/docker.sock which is a little bit non-default.)

How do you mean ‘more involved’? /info is a legitimate endpoint right?

None of the examples I’ve tried work:

neil@luna:~$ docker images |wc -l
44
neil@luna:~$ curl --unix-socket /run/docker.sock -X GET http://images/json?all=0
{“message”:“page not found”}

neil@luna:~$ docker ps -a|wc -l
12
neil@luna:~$ curl --unix-socket /run/docker.sock -X GET http://containers/json?all=0
{“message”:“page not found”}

Oh. Try http://docker/info. (You put “info” into the “host” part of the URL, and curl is just ignoring that part because of the --unix-socket option.)

1 Like

docker is the key. Too bad no examples shot that :frowning:

curl --unix-socket /run/docker.sock http://docker/images/json

1 Like

Thanks a lot Neil !!! Frustration was growing quickly on this one…