1.启动docker remote API的方式如下:
docker -d -H uninx:///var/run/docker.sock -H tcp://0.0.0.0:5678
2.但是为了伴随开机启动需要修改响应的配置,修改如下:
# vi /etc/sysconfig/docker other_args=" -H unix:///var/run/docker.sock -H tcp://0.0.0.0:5678"
# service docker restart
3.验证配置
# docker -H localhost:5678 version Client version: 1.7.1 Client API version: 1.19 Go version (client): go1.4.2 Git commit (client): 786b29d/1.7.1 OS/Arch (client): linux/amd64 Server version: 1.7.1 Server API version: 1.19 Go version (server): go1.4.2 Git commit (server): 786b29d/1.7.1 OS/Arch (server): linux/amd64
4. 通过加 -v参数来获取更详细的信息
# curl -v -X GET localhost:5678/_ping * About to connect() to localhost port 5678 (#0) * Trying ::1... connected * Connected to localhost (::1) port 5678 (#0) > GET /_ping HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: localhost:5678 > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 14 Jul 2016 02:33:04 GMT < Content-Length: 2 < Content-Type: text/plain; charset=utf-8 < * Connection #0 to host localhost left intact * Closing connection #0
5.查看镜像的信息
# curl -X GET http://localhost:5678/images/json |python -m json.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 103 2381 0 2381 0 0 6035 0 --:--:-- --:--:-- --:--:-- 6058 [ { "Created": 1468305277, "Id": "2100ac66596ec5538b791a6bba9747f6c0a5f31cb4cd201fdd3b45c869e3a6a9", "Labels": {}, "ParentId": "1d5232051b93ace0db217c4a157760147f5764d57601d2a1a6dcb5019f447fce", "RepoDigests": [ "<none>@<none>" ], "RepoTags": [ "<none>:<none>" ], "Size": 0, "VirtualSize": 269858105 } ]