docker_remote_api_v1.3.rst 22 KB

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