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

标签 docker docker-api

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

我的 docker 守护进程有什么问题吗?如何从 docker unix-socket 获取容器信息?
docker deamon 绝对启动。

最佳答案

我关注了这个页面:https://docs.docker.com/engine/reference/api/docker_remote_api/#/v1-23-api-changes ,它建议我们使用 curl 7.40 或更高版本,命令 curl --unix-socket /var/run/docker.sock http:/containers/json .可以发现有一个非公开网址http:/containers/json在这个命令中。

然后我下载了最新的curl 7.50.3,这个问题的关键是curl的版本,我们应该像下面这样执行:

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

更多细节观看此页面。 https://superuser.com/questions/834307/can-curl-send-requests-to-sockets .希望它可以帮助其他一些困惑的人。

关于docker - "404 page not found"执行时 `curl --unix-socket/var/run/docker.sock http:/containers/json`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39630316/

相关文章:

docker - 我如何在 Centos 7 上公开 Docker Remote API?

docker - 是否存储了Docker远程API日志?

mysql - 下一个云和mysql设置: authentication method unknown to the client

python - 在 Docker 容器中安装 python 时执行格式错误

opencv - 如何永久保存docker容器中的数据和软件?

docker - 将目录绑定(bind)到 docker 容器

python - 使用 Docker Registry API 客户端在 Docker Hub 上创建私有(private)存储库

docker - 在没有Docker守护程序的情况下调用Docker API

rest - 如何使用 Docker Registry HTTP API V2 获取 docker 注册表中所有存储库的列表?

使用 Docker 的 PHP 开发环境