docker_remote_api_v1.4.rst 22 KB

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