docker_remote_api_v1.4.rst 23 KB

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