Docker Community Forums

Share and learn in the Docker community.

API via socket returns 'page not found'


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?

Nothing; the error message you quote exactly matches the sample error at 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
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
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