docker_remote_api_v1.4.rst 22 KB

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