Before we go any further, let's take a look at how we're going to use the curl and Python tools.
The foundation of CURL
For Curl This tool, you can support DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, Imaps, LDAP, LDAPS, POP3, Pop3s, RTMP, RTSP, SCP, SFTP, SMTP, Smtps,telnet and TFTP protocol. In this open source summer camp project, I mainly use this tool to complete the HTTP request.
One of its basic uses is:
Curl theegg.me/docker/
It returns a section of HTML code:
404 Page Not Found
If you add an argument-I (full name--include):
Curl-i theegg.me/docker/
You'll see the HTML code that includes the header:
http/1.1 404 Not Found
server:nginx
Date:thu, June 2014 08:49:50 GMT content-type:text/plain
; charset=utf -8
content-length:19
connection:keep-alive
404 Page Not Found
In addition to this parameter-I, the parameter we commonly use is-------------------------------------------------------- But there's no way that this example can be done by everyone.
Curl--include
--request POST
--header "Content-type:application/json"--data
' {"name": "Nuthanger Farm" , "location": {"lat": 51.244031, "Long": -1.263224}} '
http://localhost:9000/places
As you can see, I use the include parameter to indicate that I want to include the header information, also indicate that the requested method is POST, and indicate that the requested resource is JSON and the data sent is a JSON string. With this basic knowledge, we are enough to study the Docker remote API.
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/
It involves Python.
The content involved in Python is actually very simple, just a formatting tool, Json.tool, when we use the pipeline and curl output to match.
Curl Theegg.me/docker/images/json | Python-mjsontool
You can see the following results:
[
{
"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
}
]
Of course, there is a small section of the curl download of the progress instructions I ignored. If you want to keep curl quiet, do not show the progress bar, you can add a parameter-s, that is,--silent