docker_remote_api_v1.2.rst 20 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013
  1. :title: Remote API v1.2
  2. :description: API Documentation for Docker
  3. :keywords: API, Docker, rcli, REST, documentation
  4. ======================
  5. Docker Remote API v1.2
  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. {{ authConfig }}
  482. **Example response**:
  483. .. sourcecode:: http
  484. HTTP/1.1 200 OK
  485. Content-Type: application/json
  486. {"status":"Pushing..."}
  487. {"status":"Pushing", "progress":"1/? (n/a)"}
  488. {"error":"Invalid..."}
  489. ...
  490. :query registry: the registry you wan to push, optional
  491. :statuscode 200: no error
  492. :statuscode 404: no such image
  493. :statuscode 500: server error
  494. Tag an image into a repository
  495. ******************************
  496. .. http:post:: /images/(name)/tag
  497. Tag the image ``name`` into a repository
  498. **Example request**:
  499. .. sourcecode:: http
  500. POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
  501. **Example response**:
  502. .. sourcecode:: http
  503. HTTP/1.1 200 OK
  504. :query repo: The repository to tag in
  505. :query force: 1/True/true or 0/False/false, default false
  506. :statuscode 200: no error
  507. :statuscode 400: bad parameter
  508. :statuscode 404: no such image
  509. :statuscode 409: conflict
  510. :statuscode 500: server error
  511. Remove an image
  512. ***************
  513. .. http:delete:: /images/(name)
  514. Remove the image ``name`` from the filesystem
  515. **Example request**:
  516. .. sourcecode:: http
  517. DELETE /images/test HTTP/1.1
  518. **Example response**:
  519. .. sourcecode:: http
  520. HTTP/1.1 200 OK
  521. Content-type: application/json
  522. [
  523. {"Untagged":"3e2f21a89f"},
  524. {"Deleted":"3e2f21a89f"},
  525. {"Deleted":"53b4f83ac9"}
  526. ]
  527. :statuscode 204: no error
  528. :statuscode 404: no such image
  529. :statuscode 409: conflict
  530. :statuscode 500: server error
  531. Search images
  532. *************
  533. .. http:get:: /images/search
  534. Search for an image in the docker index
  535. **Example request**:
  536. .. sourcecode:: http
  537. GET /images/search?term=sshd HTTP/1.1
  538. **Example response**:
  539. .. sourcecode:: http
  540. HTTP/1.1 200 OK
  541. Content-Type: application/json
  542. [
  543. {
  544. "Name":"cespare/sshd",
  545. "Description":""
  546. },
  547. {
  548. "Name":"johnfuller/sshd",
  549. "Description":""
  550. },
  551. {
  552. "Name":"dhrp/mongodb-sshd",
  553. "Description":""
  554. }
  555. ]
  556. :query term: term to search
  557. :statuscode 200: no error
  558. :statuscode 500: server error
  559. 2.3 Misc
  560. --------
  561. Build an image from Dockerfile via stdin
  562. ****************************************
  563. .. http:post:: /build
  564. Build an image from Dockerfile via stdin
  565. **Example request**:
  566. .. sourcecode:: http
  567. POST /build HTTP/1.1
  568. {{ STREAM }}
  569. **Example response**:
  570. .. sourcecode:: http
  571. HTTP/1.1 200 OK
  572. {{ STREAM }}
  573. :query t: tag to be applied to the resulting image in case of success
  574. :statuscode 200: no error
  575. :statuscode 500: server error
  576. Check auth configuration
  577. ************************
  578. .. http:post:: /auth
  579. Get the default username and email
  580. **Example request**:
  581. .. sourcecode:: http
  582. POST /auth HTTP/1.1
  583. Content-Type: application/json
  584. {
  585. "username":"hannibal",
  586. "password:"xxxx",
  587. "email":"hannibal@a-team.com"
  588. }
  589. **Example response**:
  590. .. sourcecode:: http
  591. HTTP/1.1 200 OK
  592. :statuscode 200: no error
  593. :statuscode 204: no error
  594. :statuscode 500: server error
  595. Display system-wide information
  596. *******************************
  597. .. http:get:: /info
  598. Display system-wide information
  599. **Example request**:
  600. .. sourcecode:: http
  601. GET /info HTTP/1.1
  602. **Example response**:
  603. .. sourcecode:: http
  604. HTTP/1.1 200 OK
  605. Content-Type: application/json
  606. {
  607. "Containers":11,
  608. "Images":16,
  609. "Debug":false,
  610. "NFd": 11,
  611. "NGoroutines":21,
  612. "MemoryLimit":true,
  613. "SwapLimit":false
  614. }
  615. :statuscode 200: no error
  616. :statuscode 500: server error
  617. Show the docker version information
  618. ***********************************
  619. .. http:get:: /version
  620. Show the docker version information
  621. **Example request**:
  622. .. sourcecode:: http
  623. GET /version HTTP/1.1
  624. **Example response**:
  625. .. sourcecode:: http
  626. HTTP/1.1 200 OK
  627. Content-Type: application/json
  628. {
  629. "Version":"0.2.2",
  630. "GitCommit":"5a2a5cc+CHANGES",
  631. "GoVersion":"go1.0.3"
  632. }
  633. :statuscode 200: no error
  634. :statuscode 500: server error
  635. Create a new image from a container's changes
  636. *********************************************
  637. .. http:post:: /commit
  638. Create a new image from a container's changes
  639. **Example request**:
  640. .. sourcecode:: http
  641. POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  642. **Example response**:
  643. .. sourcecode:: http
  644. HTTP/1.1 201 OK
  645. Content-Type: application/vnd.docker.raw-stream
  646. {"Id":"596069db4bf5"}
  647. :query container: source container
  648. :query repo: repository
  649. :query tag: tag
  650. :query m: commit message
  651. :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
  652. :query run: config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs":["22"]})
  653. :statuscode 201: no error
  654. :statuscode 404: no such container
  655. :statuscode 500: server error
  656. 3. Going further
  657. ================
  658. 3.1 Inside 'docker run'
  659. -----------------------
  660. Here are the steps of 'docker run' :
  661. * Create the container
  662. * If the status code is 404, it means the image doesn't exists:
  663. * Try to pull it
  664. * Then retry to create the container
  665. * Start the container
  666. * If you are not in detached mode:
  667. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  668. * If in detached mode or only stdin is attached:
  669. * Display the container's id
  670. 3.2 Hijacking
  671. -------------
  672. 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.
  673. 3.3 CORS Requests
  674. -----------------
  675. To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
  676. docker -d -H="192.168.1.9:4243" -api-enable-cors