docker_remote_api_v1.0.rst 20 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  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 201 OK
  496. :query repo: The repository to tag in
  497. :query force: 1/True/true or 0/False/false, default false
  498. :statuscode 201: 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. Content-Type: application/json
  644. {
  645. "Cmd": ["cat", "/world"],
  646. "PortSpecs":["22"]
  647. }
  648. **Example response**:
  649. .. sourcecode:: http
  650. HTTP/1.1 201 OK
  651. Content-Type: application/vnd.docker.raw-stream
  652. {"Id":"596069db4bf5"}
  653. :query container: source container
  654. :query repo: repository
  655. :query tag: tag
  656. :query m: commit message
  657. :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
  658. :statuscode 201: no error
  659. :statuscode 404: no such container
  660. :statuscode 500: server error
  661. 3. Going further
  662. ================
  663. 3.1 Inside 'docker run'
  664. -----------------------
  665. Here are the steps of 'docker run' :
  666. * Create the container
  667. * If the status code is 404, it means the image doesn't exists:
  668. * Try to pull it
  669. * Then retry to create the container
  670. * Start the container
  671. * If you are not in detached mode:
  672. * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
  673. * If in detached mode or only stdin is attached:
  674. * Display the container's id
  675. 3.2 Hijacking
  676. -------------
  677. In this first version of the API, some of the endpoints, like /attach, /pull or /push uses hijacking to transport stdin,
  678. stdout and stderr on the same socket. This might change in the future.