docker_remote_api_v1.0.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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.0
  5. :description: API Documentation for Docker
  6. :keywords: API, Docker, rcli, REST, documentation
  7. ======================
  8. Docker Remote API v1.0
  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/vnd.docker.raw-stream
  383. {{ STREAM }}
  384. :query fromImage: name of the image to pull
  385. :query fromSrc: source to import, - means stdin
  386. :query repo: repository
  387. :query tag: tag
  388. :query registry: the registry to pull from
  389. :statuscode 200: no error
  390. :statuscode 500: server error
  391. Insert a file in an image
  392. *************************
  393. .. http:post:: /images/(name)/insert
  394. Insert a file from ``url`` in the image ``name`` at ``path``
  395. **Example request**:
  396. .. sourcecode:: http
  397. POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
  398. **Example response**:
  399. .. sourcecode:: http
  400. HTTP/1.1 200 OK
  401. {{ STREAM }}
  402. :statuscode 200: no error
  403. :statuscode 500: server error
  404. Inspect an image
  405. ****************
  406. .. http:get:: /images/(name)/json
  407. Return low-level information on the image ``name``
  408. **Example request**:
  409. .. sourcecode:: http
  410. GET /images/centos/json HTTP/1.1
  411. **Example response**:
  412. .. sourcecode:: http
  413. HTTP/1.1 200 OK
  414. Content-Type: application/json
  415. {
  416. "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  417. "parent":"27cf784147099545",
  418. "created":"2013-03-23T22:24:18.818426-07:00",
  419. "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  420. "container_config":
  421. {
  422. "Hostname":"",
  423. "User":"",
  424. "Memory":0,
  425. "MemorySwap":0,
  426. "AttachStdin":false,
  427. "AttachStdout":false,
  428. "AttachStderr":false,
  429. "PortSpecs":null,
  430. "Tty":true,
  431. "OpenStdin":true,
  432. "StdinOnce":false,
  433. "Env":null,
  434. "Cmd": ["/bin/bash"]
  435. ,"Dns":null,
  436. "Image":"centos",
  437. "Volumes":null,
  438. "VolumesFrom":""
  439. }
  440. }
  441. :statuscode 200: no error
  442. :statuscode 404: no such image
  443. :statuscode 500: server error
  444. Get the history of an image
  445. ***************************
  446. .. http:get:: /images/(name)/history
  447. Return the history of the image ``name``
  448. **Example request**:
  449. .. sourcecode:: http
  450. GET /images/fedora/history HTTP/1.1
  451. **Example response**:
  452. .. sourcecode:: http
  453. HTTP/1.1 200 OK
  454. Content-Type: application/json
  455. [
  456. {
  457. "Id":"b750fe79269d",
  458. "Created":1364102658,
  459. "CreatedBy":"/bin/bash"
  460. },
  461. {
  462. "Id":"27cf78414709",
  463. "Created":1364068391,
  464. "CreatedBy":""
  465. }
  466. ]
  467. :statuscode 200: no error
  468. :statuscode 404: no such image
  469. :statuscode 500: server error
  470. Push an image on the registry
  471. *****************************
  472. .. http:post:: /images/(name)/push
  473. Push the image ``name`` on the registry
  474. **Example request**:
  475. .. sourcecode:: http
  476. POST /images/test/push HTTP/1.1
  477. **Example response**:
  478. .. sourcecode:: http
  479. HTTP/1.1 200 OK
  480. Content-Type: application/vnd.docker.raw-stream
  481. {{ STREAM }}
  482. :query registry: the registry you wan to push, optional
  483. :statuscode 200: no error
  484. :statuscode 404: no such image
  485. :statuscode 500: server error
  486. Tag an image into a repository
  487. ******************************
  488. .. http:post:: /images/(name)/tag
  489. Tag the image ``name`` into a repository
  490. **Example request**:
  491. .. sourcecode:: http
  492. POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
  493. **Example response**:
  494. .. sourcecode:: http
  495. HTTP/1.1 200 OK
  496. :query repo: The repository to tag in
  497. :query force: 1/True/true or 0/False/false, default false
  498. :statuscode 200: no error
  499. :statuscode 400: bad parameter
  500. :statuscode 404: no such image
  501. :statuscode 500: server error
  502. Remove an image
  503. ***************
  504. .. http:delete:: /images/(name)
  505. Remove the image ``name`` from the filesystem
  506. **Example request**:
  507. .. sourcecode:: http
  508. DELETE /images/test HTTP/1.1
  509. **Example response**:
  510. .. sourcecode:: http
  511. HTTP/1.1 204 OK
  512. :statuscode 204: no error
  513. :statuscode 404: no such image
  514. :statuscode 500: server error
  515. Search images
  516. *************
  517. .. http:get:: /images/search
  518. Search for an image in the docker index
  519. **Example request**:
  520. .. sourcecode:: http
  521. GET /images/search?term=sshd HTTP/1.1
  522. **Example response**:
  523. .. sourcecode:: http
  524. HTTP/1.1 200 OK
  525. Content-Type: application/json
  526. [
  527. {
  528. "Name":"cespare/sshd",
  529. "Description":""
  530. },
  531. {
  532. "Name":"johnfuller/sshd",
  533. "Description":""
  534. },
  535. {
  536. "Name":"dhrp/mongodb-sshd",
  537. "Description":""
  538. }
  539. ]
  540. :query term: term to search
  541. :statuscode 200: no error
  542. :statuscode 500: server error
  543. 2.3 Misc
  544. --------
  545. Build an image from Dockerfile via stdin
  546. ****************************************
  547. .. http:post:: /build
  548. Build an image from Dockerfile via stdin
  549. **Example request**:
  550. .. sourcecode:: http
  551. POST /build HTTP/1.1
  552. {{ STREAM }}
  553. **Example response**:
  554. .. sourcecode:: http
  555. HTTP/1.1 200 OK
  556. {{ STREAM }}
  557. :query t: repository name to be applied to the resulting image in case of success
  558. :statuscode 200: no error
  559. :statuscode 500: server error
  560. Get default username and email
  561. ******************************
  562. .. http:get:: /auth
  563. Get the default username and email
  564. **Example request**:
  565. .. sourcecode:: http
  566. GET /auth HTTP/1.1
  567. **Example response**:
  568. .. sourcecode:: http
  569. HTTP/1.1 200 OK
  570. Content-Type: application/json
  571. {
  572. "username":"hannibal",
  573. "email":"hannibal@a-team.com"
  574. }
  575. :statuscode 200: no error
  576. :statuscode 500: server error
  577. Check auth configuration and store it
  578. *************************************
  579. .. http:post:: /auth
  580. Get the default username and email
  581. **Example request**:
  582. .. sourcecode:: http
  583. POST /auth HTTP/1.1
  584. Content-Type: application/json
  585. {
  586. "username":"hannibal",
  587. "password:"xxxx",
  588. "email":"hannibal@a-team.com"
  589. }
  590. **Example response**:
  591. .. sourcecode:: http
  592. HTTP/1.1 200 OK
  593. :statuscode 200: no error
  594. :statuscode 204: no error
  595. :statuscode 500: server error
  596. Display system-wide information
  597. *******************************
  598. .. http:get:: /info
  599. Display system-wide information
  600. **Example request**:
  601. .. sourcecode:: http
  602. GET /info HTTP/1.1
  603. **Example response**:
  604. .. sourcecode:: http
  605. HTTP/1.1 200 OK
  606. Content-Type: application/json
  607. {
  608. "Containers":11,
  609. "Images":16,
  610. "Debug":false,
  611. "NFd": 11,
  612. "NGoroutines":21,
  613. "MemoryLimit":true,
  614. "SwapLimit":false
  615. }
  616. :statuscode 200: no error
  617. :statuscode 500: server error
  618. Show the docker version information
  619. ***********************************
  620. .. http:get:: /version
  621. Show the docker version information
  622. **Example request**:
  623. .. sourcecode:: http
  624. GET /version HTTP/1.1
  625. **Example response**:
  626. .. sourcecode:: http
  627. HTTP/1.1 200 OK
  628. Content-Type: application/json
  629. {
  630. "Version":"0.2.2",
  631. "GitCommit":"5a2a5cc+CHANGES",
  632. "GoVersion":"go1.0.3"
  633. }
  634. :statuscode 200: no error
  635. :statuscode 500: server error
  636. Create a new image from a container's changes
  637. *********************************************
  638. .. http:post:: /commit
  639. Create a new image from a container's changes
  640. **Example request**:
  641. .. sourcecode:: http
  642. POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  643. **Example response**:
  644. .. sourcecode:: http
  645. HTTP/1.1 201 OK
  646. Content-Type: application/vnd.docker.raw-stream
  647. {"Id":"596069db4bf5"}
  648. :query container: source container
  649. :query repo: repository
  650. :query tag: tag
  651. :query m: commit message
  652. :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
  653. :query run: config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs":["22"]})
  654. :statuscode 201: no error
  655. :statuscode 404: no such container
  656. :statuscode 500: server error
  657. 3. Going further
  658. ================
  659. 3.1 Inside 'docker run'
  660. -----------------------
  661. Here are the steps of 'docker run' :
  662. * Create the container
  663. * If the status code is 404, it means the image doesn't exists:
  664. * Try to pull it
  665. * Then retry to create the container
  666. * Start the container
  667. * If you are not in detached mode:
  668. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  669. * If in detached mode or only stdin is attached:
  670. * Display the container's id
  671. 3.2 Hijacking
  672. -------------
  673. In this first version of the API, some of the endpoints, like /attach, /pull or /push uses hijacking to transport stdin,
  674. stdout and stderr on the same socket. This might change in the future.