docker_remote_api.rst 20 KB

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