docker_remote_api_v1.3.rst 23 KB

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