[Open Source summer camp] [4] Docker remote API image, dockerremote
List Images
List images. There are two optional parameters: all, filter, and all. The optional values are 0, False, false, and 1, True, and true. The default value is 0; filter is a json file containing a filter object, in the form of '{"dangling": ["true"]}'
GET /images/json
We can try to request
curl -s -XGET theegg.me/docker/images/json?all=0 | python -mjson.tool
You can see the following return values:
[ { "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 }]
Meanings of returned values:
Created: the creation time. This is a UNIX time, starting from 1970, in seconds.
Id: A SHA256 value, which is the Id of the image.
ParentId: A SHA256 value, which is the ID of the image's parent image.
RepoTags: it is a string array that indicates its tag in the repository. An image may contain multiple tags.
Size: the actual Size of the image, that is, the Size of the image occupied by the hard disk space.
VirtualSize: indicates the virtual size of the image, or the size of the image. The actual size of the image is the virtual size of the parent image minus the virtual size of the image.
Create an image
POST /images/create
Request Parameters:
-** FromImage **-image name-** fromSrc **-image source, that is, the standard input-** repo **-repository-** tag **-tag-** registry **-from which registry
Sample request:
curl -s -XPOST theegg.me/docker/images/create?fromImage=base
Return Value:
Start:
{ "status": "Pulling repository base"}
In process:
{ "status": "Downloading", "progressDetail": { "current": 528384, "total": 94863360, "start": 1405907686 }, "progress": "[> ] 528.4 kB/94.86 MB 6m30s", "id": "27cf78414709"}
When an error occurs: (from the official documentation, but the actual curl operation displays 504 timeout, the cause has not been identified)
{"error":"Invalid..."}
Meaning of return value:
Status: status, current operation status
ProgressDetail: indicates the progress details, which contains three values: current position, total number, and start
Progress: indicates the progress. It is a progress display that can be directly output (ascii chart)
Id: identifier
Error: error message