docker_remote_api_v1.2.rst 20 KB

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