列出镜像,有两个可选參数,一个是all,一个是filter,all可选值有,0/False/false,1/True/true,默觉得0;filter是一个包括一个过滤对象的json,形式如‘{"dangling":["true"]}‘
GET /images/json
我们能够尝试请求一下
curl -s -XGET theegg.me/docker/images/json?all=0 | python -mjson.tool
能够看到例如以下的返回值:
[ { "Created": 1405461399, "Id": "88b42ffd1f7cc87c46edf70924b3e24f18da0eb69337deff4db2979d6e1032d8", "ParentId": "c69cab00d6ef21152755a3de928625d7a02860ebe918b8fe9d1dd6aba15229b2", "RepoTags": [ "fedora:latest" ], "Size": 373742581, "VirtualSize": 373742581 }, { "Created": 1403128361, "Id": "e54ca5efa2e962582a223ca9810f7f1b62ea9b5c3975d14a5da79d3bf6020f37", "ParentId": "6c37f792ddacad573016e6aea7fc9fb377127b4767ce6104c9f869314a12041e", "RepoTags": [ "ubuntu:latest" ], "Size": 8, "VirtualSize": 276100357 } ]
返回值相应的含义:
Created:创建的时间,这是一个UNIX时间,以1970为起点,单位为秒
Id:是一个SHA256值,是该镜像的标识。
ParentId:是一个SHA256值,是该镜像的父镜像的标识。
RepoTags:是一个字符串数组,是标明在仓库中它的标签。一个镜像可能会带有多个标签。
Size:是镜像的实际的大小,即镜像占硬盘空间的大小。
VirtualSize:是镜像的虚拟大小,或者就是镜像的大小。镜像的实际大小为父镜像的虚拟大小减去该镜像的虚拟大小。
POST /images/create
- **fromImage** – 镜像的名字 - **fromSrc** – 镜像的来源,即标准输入 - **repo** – 仓库 - **tag** – 标签 - **registry** – 从哪个registry
演示样例请求:
curl -s -XPOST theegg.me/docker/images/create?fromImage=base
開始:
{ "status": "Pulling repository base" }
过程中:
{ "status": "Downloading", "progressDetail": { "current": 528384, "total": 94863360, "start": 1405907686 }, "progress": "[> ] 528.4 kB/94.86 MB 6m30s", "id": "27cf78414709" }
{"error":"Invalid..."}
返回值含义:
status:表示状态,当前操作状态
progressDetail:表示进度细节,里面包括三个值,current当前位置,total总共多少,start从何处開始
progress:表示进度,是一个能直接输出的进度显示条(ascii图)
id:标示符
error:出错信息
GET /images/(name)/json
curl -s -XGET theegg.me/docker/images/base/json | python -mjson.tool
{ "Architecture": "", "Author": "", "Comment": "", "Config": null, "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", "ContainerConfig": { "AttachStderr": false, "AttachStdin": false, "AttachStdout": false, "Cmd": [ "/bin/bash" ], "CpuShares": 0, "Cpuset": "", "Domainname": "", "Entrypoint": null, "Env": null, "ExposedPorts": null, "Hostname": "", "Image": "base", "Memory": 0, "MemorySwap": 0, "NetworkDisabled": false, "OnBuild": null, "OpenStdin": true, "PortSpecs": null, "StdinOnce": false, "Tty": true, "User": "", "Volumes": null, "WorkingDir": "" }, "Created": "2013-03-23T22:24:18.818426-07:00", "DockerVersion": "", "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", "Os": "", "Parent": "27cf784147099545", "Size": 77 }
GET /images/(name)/history
curl -XGET -s theegg.me/docker/images/base/history | python -mjson.tool [ { "Created": 1364102658, "CreatedBy": "/bin/bash", "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", "Size": 77, "Tags": [ "base:latest", "base:ubuntu-12.10", "base:ubuntu-quantal", "base:ubuntu-quantl" ] }, { "Created": 1364068391, "CreatedBy": "", "Id": "27cf784147099545", "Size": 175306958, "Tags": null } ]
POST /images/(name)/push
POST /images/(name)/tag
curl -XPOST theegg.me/docker/images/base/tag?repo=a -i
HTTP/1.1 201 Created Server: nginx Date: Tue, 29 Jul 2014 02:26:24 GMT Content-Type: text/plain; charset=utf-8 Content-Length: 0 Connection: keep-alive
DELETE /images/(name)
curl -XDELETE theegg.me/docker/images/base [ { "Untagged": "base:latest" } ]
GET /images/search
curl -XGET -s theegg.me/docker/images/search?term=sshd | python -mjson.tool
[ { "description": "SSH Daemon created in the ssh daemon documentation example", "is_official": false, "is_trusted": false, "name": "dhrp/sshd", "star_count": 5 }, { "description": "Ubuntu 13.10 with openssh based on the stackbrew/ubuntu:13.10 image.", "is_official": false, "is_trusted": false, "name": "stephens/sshd", "star_count": 2 },... ]
[开源夏令营][四] Docker remote API 之 镜像篇,布布扣,bubuko.com
[开源夏令营][四] Docker remote API 之 镜像篇
原文:http://www.cnblogs.com/yxwkf/p/3878420.html