docker_remote_api_v1.1.rst 20 KB

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