docker_remote_api_v1.1.rst 20 KB

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