docker_remote_api_v1.4.rst 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. :title: Remote API v1.4
  2. :description: API Documentation for Docker
  3. :keywords: API, Docker, rcli, REST, documentation
  4. :orphan:
  5. ======================
  6. Docker Remote API v1.4
  7. ======================
  8. .. contents:: Table of Contents
  9. 1. Brief introduction
  10. =====================
  11. - The Remote API is replacing rcli
  12. - Default port in the docker daemon is 4243
  13. - The API tends to be REST, but for some complex commands, like attach or pull, the HTTP connection is hijacked to transport stdout stdin and stderr
  14. 2. Endpoints
  15. ============
  16. 2.1 Containers
  17. --------------
  18. List containers
  19. ***************
  20. .. http:get:: /containers/json
  21. List containers
  22. **Example request**:
  23. .. sourcecode:: http
  24. GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
  25. **Example response**:
  26. .. sourcecode:: http
  27. HTTP/1.1 200 OK
  28. Content-Type: application/json
  29. [
  30. {
  31. "Id": "8dfafdbc3a40",
  32. "Image": "base:latest",
  33. "Command": "echo 1",
  34. "Created": 1367854155,
  35. "Status": "Exit 0",
  36. "Ports":"",
  37. "SizeRw":12288,
  38. "SizeRootFs":0
  39. },
  40. {
  41. "Id": "9cd87474be90",
  42. "Image": "base:latest",
  43. "Command": "echo 222222",
  44. "Created": 1367854155,
  45. "Status": "Exit 0",
  46. "Ports":"",
  47. "SizeRw":12288,
  48. "SizeRootFs":0
  49. },
  50. {
  51. "Id": "3176a2479c92",
  52. "Image": "base:latest",
  53. "Command": "echo 3333333333333333",
  54. "Created": 1367854154,
  55. "Status": "Exit 0",
  56. "Ports":"",
  57. "SizeRw":12288,
  58. "SizeRootFs":0
  59. },
  60. {
  61. "Id": "4cb07b47f9fb",
  62. "Image": "base:latest",
  63. "Command": "echo 444444444444444444444444444444444",
  64. "Created": 1367854152,
  65. "Status": "Exit 0",
  66. "Ports":"",
  67. "SizeRw":12288,
  68. "SizeRootFs":0
  69. }
  70. ]
  71. :query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
  72. :query limit: Show ``limit`` last created containers, include non-running ones.
  73. :query since: Show only containers created since Id, include non-running ones.
  74. :query before: Show only containers created before Id, include non-running ones.
  75. :query size: 1/True/true or 0/False/false, Show the containers sizes
  76. :statuscode 200: no error
  77. :statuscode 400: bad parameter
  78. :statuscode 500: server error
  79. Create a container
  80. ******************
  81. .. http:post:: /containers/create
  82. Create a container
  83. **Example request**:
  84. .. sourcecode:: http
  85. POST /containers/create HTTP/1.1
  86. Content-Type: application/json
  87. {
  88. "Hostname":"",
  89. "User":"",
  90. "Memory":0,
  91. "MemorySwap":0,
  92. "AttachStdin":false,
  93. "AttachStdout":true,
  94. "AttachStderr":true,
  95. "PortSpecs":null,
  96. "Tty":false,
  97. "OpenStdin":false,
  98. "StdinOnce":false,
  99. "Env":null,
  100. "Cmd":[
  101. "date"
  102. ],
  103. "Dns":null,
  104. "Image":"base",
  105. "Volumes":{},
  106. "VolumesFrom":"",
  107. "WorkingDir":""
  108. }
  109. **Example response**:
  110. .. sourcecode:: http
  111. HTTP/1.1 201 OK
  112. Content-Type: application/json
  113. {
  114. "Id":"e90e34656806"
  115. "Warnings":[]
  116. }
  117. :jsonparam config: the container's configuration
  118. :statuscode 201: no error
  119. :statuscode 404: no such container
  120. :statuscode 406: impossible to attach (container not running)
  121. :statuscode 500: server error
  122. Inspect a container
  123. *******************
  124. .. http:get:: /containers/(id)/json
  125. Return low-level information on the container ``id``
  126. **Example request**:
  127. .. sourcecode:: http
  128. GET /containers/4fa6e0f0c678/json HTTP/1.1
  129. **Example response**:
  130. .. sourcecode:: http
  131. HTTP/1.1 200 OK
  132. Content-Type: application/json
  133. {
  134. "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
  135. "Created": "2013-05-07T14:51:42.041847+02:00",
  136. "Path": "date",
  137. "Args": [],
  138. "Config": {
  139. "Hostname": "4fa6e0f0c678",
  140. "User": "",
  141. "Memory": 0,
  142. "MemorySwap": 0,
  143. "AttachStdin": false,
  144. "AttachStdout": true,
  145. "AttachStderr": true,
  146. "PortSpecs": null,
  147. "Tty": false,
  148. "OpenStdin": false,
  149. "StdinOnce": false,
  150. "Env": null,
  151. "Cmd": [
  152. "date"
  153. ],
  154. "Dns": null,
  155. "Image": "base",
  156. "Volumes": {},
  157. "VolumesFrom": "",
  158. "WorkingDir":""
  159. },
  160. "State": {
  161. "Running": false,
  162. "Pid": 0,
  163. "ExitCode": 0,
  164. "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
  165. "Ghost": false
  166. },
  167. "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  168. "NetworkSettings": {
  169. "IpAddress": "",
  170. "IpPrefixLen": 0,
  171. "Gateway": "",
  172. "Bridge": "",
  173. "PortMapping": null
  174. },
  175. "SysInitPath": "/home/kitty/go/src/github.com/dotcloud/docker/bin/docker",
  176. "ResolvConfPath": "/etc/resolv.conf",
  177. "Volumes": {}
  178. }
  179. :statuscode 200: no error
  180. :statuscode 404: no such container
  181. :statuscode 500: server error
  182. List processes running inside a container
  183. *****************************************
  184. .. http:get:: /containers/(id)/top
  185. List processes running inside the container ``id``
  186. **Example request**:
  187. .. sourcecode:: http
  188. GET /containers/4fa6e0f0c678/top HTTP/1.1
  189. **Example response**:
  190. .. sourcecode:: http
  191. HTTP/1.1 200 OK
  192. Content-Type: application/json
  193. {
  194. "Titles":[
  195. "USER",
  196. "PID",
  197. "%CPU",
  198. "%MEM",
  199. "VSZ",
  200. "RSS",
  201. "TTY",
  202. "STAT",
  203. "START",
  204. "TIME",
  205. "COMMAND"
  206. ],
  207. "Processes":[
  208. ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
  209. ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
  210. ]
  211. }
  212. :query ps_args: ps arguments to use (eg. aux)
  213. :statuscode 200: no error
  214. :statuscode 404: no such container
  215. :statuscode 500: server error
  216. Inspect changes on a container's filesystem
  217. *******************************************
  218. .. http:get:: /containers/(id)/changes
  219. Inspect changes on container ``id`` 's filesystem
  220. **Example request**:
  221. .. sourcecode:: http
  222. GET /containers/4fa6e0f0c678/changes HTTP/1.1
  223. **Example response**:
  224. .. sourcecode:: http
  225. HTTP/1.1 200 OK
  226. Content-Type: application/json
  227. [
  228. {
  229. "Path":"/dev",
  230. "Kind":0
  231. },
  232. {
  233. "Path":"/dev/kmsg",
  234. "Kind":1
  235. },
  236. {
  237. "Path":"/test",
  238. "Kind":1
  239. }
  240. ]
  241. :statuscode 200: no error
  242. :statuscode 404: no such container
  243. :statuscode 500: server error
  244. Export a container
  245. ******************
  246. .. http:get:: /containers/(id)/export
  247. Export the contents of container ``id``
  248. **Example request**:
  249. .. sourcecode:: http
  250. GET /containers/4fa6e0f0c678/export HTTP/1.1
  251. **Example response**:
  252. .. sourcecode:: http
  253. HTTP/1.1 200 OK
  254. Content-Type: application/octet-stream
  255. {{ STREAM }}
  256. :statuscode 200: no error
  257. :statuscode 404: no such container
  258. :statuscode 500: server error
  259. Start a container
  260. *****************
  261. .. http:post:: /containers/(id)/start
  262. Start the container ``id``
  263. **Example request**:
  264. .. sourcecode:: http
  265. POST /containers/(id)/start HTTP/1.1
  266. Content-Type: application/json
  267. {
  268. "Binds":["/tmp:/tmp"]
  269. }
  270. **Example response**:
  271. .. sourcecode:: http
  272. HTTP/1.1 204 No Content
  273. Content-Type: text/plain
  274. :jsonparam hostConfig: the container's host configuration (optional)
  275. :statuscode 200: no error
  276. :statuscode 404: no such container
  277. :statuscode 500: server error
  278. Stop a container
  279. ****************
  280. .. http:post:: /containers/(id)/stop
  281. Stop the container ``id``
  282. **Example request**:
  283. .. sourcecode:: http
  284. POST /containers/e90e34656806/stop?t=5 HTTP/1.1
  285. **Example response**:
  286. .. sourcecode:: http
  287. HTTP/1.1 204 OK
  288. :query t: number of seconds to wait before killing the container
  289. :statuscode 204: no error
  290. :statuscode 404: no such container
  291. :statuscode 500: server error
  292. Restart a container
  293. *******************
  294. .. http:post:: /containers/(id)/restart
  295. Restart the container ``id``
  296. **Example request**:
  297. .. sourcecode:: http
  298. POST /containers/e90e34656806/restart?t=5 HTTP/1.1
  299. **Example response**:
  300. .. sourcecode:: http
  301. HTTP/1.1 204 OK
  302. :query t: number of seconds to wait before killing the container
  303. :statuscode 204: no error
  304. :statuscode 404: no such container
  305. :statuscode 500: server error
  306. Kill a container
  307. ****************
  308. .. http:post:: /containers/(id)/kill
  309. Kill the container ``id``
  310. **Example request**:
  311. .. sourcecode:: http
  312. POST /containers/e90e34656806/kill HTTP/1.1
  313. **Example response**:
  314. .. sourcecode:: http
  315. HTTP/1.1 204 OK
  316. :statuscode 204: no error
  317. :statuscode 404: no such container
  318. :statuscode 500: server error
  319. Attach to a container
  320. *********************
  321. .. http:post:: /containers/(id)/attach
  322. Attach to the container ``id``
  323. **Example request**:
  324. .. sourcecode:: http
  325. POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
  326. **Example response**:
  327. .. sourcecode:: http
  328. HTTP/1.1 200 OK
  329. Content-Type: application/vnd.docker.raw-stream
  330. {{ STREAM }}
  331. :query logs: 1/True/true or 0/False/false, return logs. Default false
  332. :query stream: 1/True/true or 0/False/false, return stream. Default false
  333. :query stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false
  334. :query stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false
  335. :query stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false
  336. :statuscode 200: no error
  337. :statuscode 400: bad parameter
  338. :statuscode 404: no such container
  339. :statuscode 500: server error
  340. Wait a container
  341. ****************
  342. .. http:post:: /containers/(id)/wait
  343. Block until container ``id`` stops, then returns the exit code
  344. **Example request**:
  345. .. sourcecode:: http
  346. POST /containers/16253994b7c4/wait HTTP/1.1
  347. **Example response**:
  348. .. sourcecode:: http
  349. HTTP/1.1 200 OK
  350. Content-Type: application/json
  351. {"StatusCode":0}
  352. :statuscode 200: no error
  353. :statuscode 404: no such container
  354. :statuscode 500: server error
  355. Remove a container
  356. *******************
  357. .. http:delete:: /containers/(id)
  358. Remove the container ``id`` from the filesystem
  359. **Example request**:
  360. .. sourcecode:: http
  361. DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  362. **Example response**:
  363. .. sourcecode:: http
  364. HTTP/1.1 204 OK
  365. :query v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false
  366. :statuscode 204: no error
  367. :statuscode 400: bad parameter
  368. :statuscode 404: no such container
  369. :statuscode 500: server error
  370. Copy files or folders from a container
  371. **************************************
  372. .. http:post:: /containers/(id)/copy
  373. Copy files or folders of container ``id``
  374. **Example request**:
  375. .. sourcecode:: http
  376. POST /containers/4fa6e0f0c678/copy HTTP/1.1
  377. Content-Type: application/json
  378. {
  379. "Resource":"test.txt"
  380. }
  381. **Example response**:
  382. .. sourcecode:: http
  383. HTTP/1.1 200 OK
  384. Content-Type: application/octet-stream
  385. {{ STREAM }}
  386. :statuscode 200: no error
  387. :statuscode 404: no such container
  388. :statuscode 500: server error
  389. 2.2 Images
  390. ----------
  391. List Images
  392. ***********
  393. .. http:get:: /images/(format)
  394. List images ``format`` could be json or viz (json default)
  395. **Example request**:
  396. .. sourcecode:: http
  397. GET /images/json?all=0 HTTP/1.1
  398. **Example response**:
  399. .. sourcecode:: http
  400. HTTP/1.1 200 OK
  401. Content-Type: application/json
  402. [
  403. {
  404. "Repository":"base",
  405. "Tag":"ubuntu-12.10",
  406. "Id":"b750fe79269d",
  407. "Created":1364102658,
  408. "Size":24653,
  409. "VirtualSize":180116135
  410. },
  411. {
  412. "Repository":"base",
  413. "Tag":"ubuntu-quantal",
  414. "Id":"b750fe79269d",
  415. "Created":1364102658,
  416. "Size":24653,
  417. "VirtualSize":180116135
  418. }
  419. ]
  420. **Example request**:
  421. .. sourcecode:: http
  422. GET /images/viz HTTP/1.1
  423. **Example response**:
  424. .. sourcecode:: http
  425. HTTP/1.1 200 OK
  426. Content-Type: text/plain
  427. digraph docker {
  428. "d82cbacda43a" -> "074be284591f"
  429. "1496068ca813" -> "08306dc45919"
  430. "08306dc45919" -> "0e7893146ac2"
  431. "b750fe79269d" -> "1496068ca813"
  432. base -> "27cf78414709" [style=invis]
  433. "f71189fff3de" -> "9a33b36209ed"
  434. "27cf78414709" -> "b750fe79269d"
  435. "0e7893146ac2" -> "d6434d954665"
  436. "d6434d954665" -> "d82cbacda43a"
  437. base -> "e9aa60c60128" [style=invis]
  438. "074be284591f" -> "f71189fff3de"
  439. "b750fe79269d" [label="b750fe79269d\nbase",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  440. "e9aa60c60128" [label="e9aa60c60128\nbase2",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  441. "9a33b36209ed" [label="9a33b36209ed\ntest",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
  442. base [style=invisible]
  443. }
  444. :query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
  445. :statuscode 200: no error
  446. :statuscode 400: bad parameter
  447. :statuscode 500: server error
  448. Create an image
  449. ***************
  450. .. http:post:: /images/create
  451. Create an image, either by pull it from the registry or by importing it
  452. **Example request**:
  453. .. sourcecode:: http
  454. POST /images/create?fromImage=base HTTP/1.1
  455. **Example response**:
  456. .. sourcecode:: http
  457. HTTP/1.1 200 OK
  458. Content-Type: application/json
  459. {"status":"Pulling..."}
  460. {"status":"Pulling", "progress":"1/? (n/a)"}
  461. {"error":"Invalid..."}
  462. ...
  463. :query fromImage: name of the image to pull
  464. :query fromSrc: source to import, - means stdin
  465. :query repo: repository
  466. :query tag: tag
  467. :query registry: the registry to pull from
  468. :statuscode 200: no error
  469. :statuscode 500: server error
  470. Insert a file in a image
  471. ************************
  472. .. http:post:: /images/(name)/insert
  473. Insert a file from ``url`` in the image ``name`` at ``path``
  474. **Example request**:
  475. .. sourcecode:: http
  476. POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
  477. **Example response**:
  478. .. sourcecode:: http
  479. HTTP/1.1 200 OK
  480. Content-Type: application/json
  481. {"status":"Inserting..."}
  482. {"status":"Inserting", "progress":"1/? (n/a)"}
  483. {"error":"Invalid..."}
  484. ...
  485. :statuscode 200: no error
  486. :statuscode 500: server error
  487. Inspect an image
  488. ****************
  489. .. http:get:: /images/(name)/json
  490. Return low-level information on the image ``name``
  491. **Example request**:
  492. .. sourcecode:: http
  493. GET /images/base/json HTTP/1.1
  494. **Example response**:
  495. .. sourcecode:: http
  496. HTTP/1.1 200 OK
  497. Content-Type: application/json
  498. {
  499. "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  500. "parent":"27cf784147099545",
  501. "created":"2013-03-23T22:24:18.818426-07:00",
  502. "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  503. "container_config":
  504. {
  505. "Hostname":"",
  506. "User":"",
  507. "Memory":0,
  508. "MemorySwap":0,
  509. "AttachStdin":false,
  510. "AttachStdout":false,
  511. "AttachStderr":false,
  512. "PortSpecs":null,
  513. "Tty":true,
  514. "OpenStdin":true,
  515. "StdinOnce":false,
  516. "Env":null,
  517. "Cmd": ["/bin/bash"]
  518. ,"Dns":null,
  519. "Image":"base",
  520. "Volumes":null,
  521. "VolumesFrom":"",
  522. "WorkingDir":""
  523. },
  524. "Size": 6824592
  525. }
  526. :statuscode 200: no error
  527. :statuscode 404: no such image
  528. :statuscode 500: server error
  529. Get the history of an image
  530. ***************************
  531. .. http:get:: /images/(name)/history
  532. Return the history of the image ``name``
  533. **Example request**:
  534. .. sourcecode:: http
  535. GET /images/base/history HTTP/1.1
  536. **Example response**:
  537. .. sourcecode:: http
  538. HTTP/1.1 200 OK
  539. Content-Type: application/json
  540. [
  541. {
  542. "Id":"b750fe79269d",
  543. "Created":1364102658,
  544. "CreatedBy":"/bin/bash"
  545. },
  546. {
  547. "Id":"27cf78414709",
  548. "Created":1364068391,
  549. "CreatedBy":""
  550. }
  551. ]
  552. :statuscode 200: no error
  553. :statuscode 404: no such image
  554. :statuscode 500: server error
  555. Push an image on the registry
  556. *****************************
  557. .. http:post:: /images/(name)/push
  558. Push the image ``name`` on the registry
  559. **Example request**:
  560. .. sourcecode:: http
  561. POST /images/test/push HTTP/1.1
  562. {{ authConfig }}
  563. **Example response**:
  564. .. sourcecode:: http
  565. HTTP/1.1 200 OK
  566. Content-Type: application/json
  567. {"status":"Pushing..."}
  568. {"status":"Pushing", "progress":"1/? (n/a)"}
  569. {"error":"Invalid..."}
  570. ...
  571. :query registry: the registry you wan to push, optional
  572. :statuscode 200: no error
  573. :statuscode 404: no such image
  574. :statuscode 500: server error
  575. Tag an image into a repository
  576. ******************************
  577. .. http:post:: /images/(name)/tag
  578. Tag the image ``name`` into a repository
  579. **Example request**:
  580. .. sourcecode:: http
  581. POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
  582. **Example response**:
  583. .. sourcecode:: http
  584. HTTP/1.1 200 OK
  585. :query repo: The repository to tag in
  586. :query force: 1/True/true or 0/False/false, default false
  587. :statuscode 200: no error
  588. :statuscode 400: bad parameter
  589. :statuscode 404: no such image
  590. :statuscode 409: conflict
  591. :statuscode 500: server error
  592. Remove an image
  593. ***************
  594. .. http:delete:: /images/(name)
  595. Remove the image ``name`` from the filesystem
  596. **Example request**:
  597. .. sourcecode:: http
  598. DELETE /images/test HTTP/1.1
  599. **Example response**:
  600. .. sourcecode:: http
  601. HTTP/1.1 200 OK
  602. Content-type: application/json
  603. [
  604. {"Untagged":"3e2f21a89f"},
  605. {"Deleted":"3e2f21a89f"},
  606. {"Deleted":"53b4f83ac9"}
  607. ]
  608. :statuscode 200: no error
  609. :statuscode 404: no such image
  610. :statuscode 409: conflict
  611. :statuscode 500: server error
  612. Search images
  613. *************
  614. .. http:get:: /images/search
  615. Search for an image in the docker index
  616. **Example request**:
  617. .. sourcecode:: http
  618. GET /images/search?term=sshd HTTP/1.1
  619. **Example response**:
  620. .. sourcecode:: http
  621. HTTP/1.1 200 OK
  622. Content-Type: application/json
  623. [
  624. {
  625. "Name":"cespare/sshd",
  626. "Description":""
  627. },
  628. {
  629. "Name":"johnfuller/sshd",
  630. "Description":""
  631. },
  632. {
  633. "Name":"dhrp/mongodb-sshd",
  634. "Description":""
  635. }
  636. ]
  637. :query term: term to search
  638. :statuscode 200: no error
  639. :statuscode 500: server error
  640. 2.3 Misc
  641. --------
  642. Build an image from Dockerfile via stdin
  643. ****************************************
  644. .. http:post:: /build
  645. Build an image from Dockerfile via stdin
  646. **Example request**:
  647. .. sourcecode:: http
  648. POST /build HTTP/1.1
  649. {{ STREAM }}
  650. **Example response**:
  651. .. sourcecode:: http
  652. HTTP/1.1 200 OK
  653. {{ STREAM }}
  654. The stream must be a tar archive compressed with one of the following algorithms:
  655. identity (no compression), gzip, bzip2, xz. The archive must include a file called
  656. `Dockerfile` at its root. It may include any number of other files, which will be
  657. accessible in the build context (See the ADD build command).
  658. The Content-type header should be set to "application/tar".
  659. :query t: repository name (and optionally a tag) to be applied to the resulting image in case of success
  660. :query q: suppress verbose build output
  661. :query nocache: do not use the cache when building the image
  662. :statuscode 200: no error
  663. :statuscode 500: server error
  664. Check auth configuration
  665. ************************
  666. .. http:post:: /auth
  667. Get the default username and email
  668. **Example request**:
  669. .. sourcecode:: http
  670. POST /auth HTTP/1.1
  671. Content-Type: application/json
  672. {
  673. "username":"hannibal",
  674. "password:"xxxx",
  675. "email":"hannibal@a-team.com"
  676. }
  677. **Example response**:
  678. .. sourcecode:: http
  679. HTTP/1.1 200 OK
  680. :statuscode 200: no error
  681. :statuscode 204: no error
  682. :statuscode 500: server error
  683. Display system-wide information
  684. *******************************
  685. .. http:get:: /info
  686. Display system-wide information
  687. **Example request**:
  688. .. sourcecode:: http
  689. GET /info HTTP/1.1
  690. **Example response**:
  691. .. sourcecode:: http
  692. HTTP/1.1 200 OK
  693. Content-Type: application/json
  694. {
  695. "Containers":11,
  696. "Images":16,
  697. "Debug":false,
  698. "NFd": 11,
  699. "NGoroutines":21,
  700. "MemoryLimit":true,
  701. "SwapLimit":false,
  702. "IPv4Forwarding":true
  703. }
  704. :statuscode 200: no error
  705. :statuscode 500: server error
  706. Show the docker version information
  707. ***********************************
  708. .. http:get:: /version
  709. Show the docker version information
  710. **Example request**:
  711. .. sourcecode:: http
  712. GET /version HTTP/1.1
  713. **Example response**:
  714. .. sourcecode:: http
  715. HTTP/1.1 200 OK
  716. Content-Type: application/json
  717. {
  718. "Version":"0.2.2",
  719. "GitCommit":"5a2a5cc+CHANGES",
  720. "GoVersion":"go1.0.3"
  721. }
  722. :statuscode 200: no error
  723. :statuscode 500: server error
  724. Create a new image from a container's changes
  725. *********************************************
  726. .. http:post:: /commit
  727. Create a new image from a container's changes
  728. **Example request**:
  729. .. sourcecode:: http
  730. POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  731. **Example response**:
  732. .. sourcecode:: http
  733. HTTP/1.1 201 OK
  734. Content-Type: application/vnd.docker.raw-stream
  735. {"Id":"596069db4bf5"}
  736. :query container: source container
  737. :query repo: repository
  738. :query tag: tag
  739. :query m: commit message
  740. :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
  741. :query run: config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs":["22"]})
  742. :statuscode 201: no error
  743. :statuscode 404: no such container
  744. :statuscode 500: server error
  745. Monitor Docker's events
  746. ***********************
  747. .. http:get:: /events
  748. Get events from docker, either in real time via streaming, or via polling (using `since`)
  749. **Example request**:
  750. .. sourcecode:: http
  751. POST /events?since=1374067924
  752. **Example response**:
  753. .. sourcecode:: http
  754. HTTP/1.1 200 OK
  755. Content-Type: application/json
  756. {"status":"create","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
  757. {"status":"start","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
  758. {"status":"stop","id":"dfdf82bd3881","from":"base:latest","time":1374067966}
  759. {"status":"destroy","id":"dfdf82bd3881","from":"base:latest","time":1374067970}
  760. :query since: timestamp used for polling
  761. :statuscode 200: no error
  762. :statuscode 500: server error
  763. 3. Going further
  764. ================
  765. 3.1 Inside 'docker run'
  766. -----------------------
  767. Here are the steps of 'docker run' :
  768. * Create the container
  769. * If the status code is 404, it means the image doesn't exists:
  770. * Try to pull it
  771. * Then retry to create the container
  772. * Start the container
  773. * If you are not in detached mode:
  774. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  775. * If in detached mode or only stdin is attached:
  776. * Display the container's id
  777. 3.2 Hijacking
  778. -------------
  779. In this version of the API, /attach, uses hijacking to transport stdin, stdout and stderr on the same socket. This might change in the future.
  780. 3.3 CORS Requests
  781. -----------------
  782. To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
  783. .. code-block:: bash
  784. docker -d -H="192.168.1.9:4243" -api-enable-cors