workhardcc
workhardcc

Reputation: 1410

"404 page not found" when exec `curl --unix-socket /var/run/docker.sock http:/containers/json`

docker version: 1.11.2
curl version: 7.50.3 (x86_64-pc-linux-gnu) libcurl/7.50.3 OpenSSL/1.0.1e zlib/1.2.7
/usr/local/sbin/bin/curl  --unix-socket /var/run/docker.sock http://images/json -v
*   Trying /var/run/docker.sock...
* Connected to images (/var/run/docker.sock) port 80 (#0)
> GET /json HTTP/1.1
> Host: images
> User-Agent: curl/7.50.3
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Thu, 22 Sep 2016 06:11:52 GMT
< Content-Length: 19
< 
404 page not found
* Curl_http_done: called premature == 0
* Connection #0 to host images left intact

Is there anything wrong with my docker daemon? How can I get the containers info from the docker unix-socket? docker deamon is absolutely started.

Upvotes: 4

Views: 3468

Answers (1)

workhardcc
workhardcc

Reputation: 1410

I followed this page:https://docs.docker.com/engine/reference/api/docker_remote_api/#/v1-23-api-changes, its suggestion us to use curl 7.40 or later, command curl --unix-socket /var/run/docker.sock http:/containers/json. You can found that there is a unavild URL http:/containers/json in this command.

Then I download the newest curl 7.50.3, the key of this problem is the curl's version, we should exec like below:

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

More detail watch this page.https://superuser.com/questions/834307/can-curl-send-requests-to-sockets. Hope it help some other people who confused.

Upvotes: 8

Related Questions