docker_remote_api.rst 20 KB

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