docker_remote_api_v1.1.rst 20 KB

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