docker_remote_api.rst 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. :title: Remote API
  2. :description: API Documentation for Docker
  3. :keywords: API, Docker, rcli, REST, documentation
  4. =================
  5. Docker Remote API
  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. - Since API version 1.2, the auth configuration is now handled client side, so the client has to send the authConfig as POST in /images/(name)/push
  14. 2. Versions
  15. ===========
  16. The current verson of the API is 1.2
  17. Calling /images/<name>/insert is the same as calling /v1.2/images/<name>/insert
  18. You can still call an old version of the api using /v1.0/images/<name>/insert
  19. :doc:`docker_remote_api_v1.2`
  20. *****************************
  21. What's new
  22. ----------
  23. The auth configuration is now handled by the client.
  24. The client should send it's authConfig as POST on each call of /images/(name)/push
  25. .. http:get:: /auth is now deprecated
  26. .. http:post:: /auth only checks the configuration but doesn't store it on the server
  27. Deleting an image is now improved, will only untag the image if it has chidrens and remove all the untagged parents if has any.
  28. .. http:post:: /images/<name>/delete now returns a JSON with the list of images deleted/untagged
  29. :doc:`docker_remote_api_v1.1`
  30. *****************************
  31. docker v0.4.0 a8ae398_
  32. What's new
  33. ----------
  34. .. http:post:: /images/create
  35. .. http:post:: /images/(name)/insert
  36. .. http:post:: /images/(name)/push
  37. Uses json stream instead of HTML hijack, it looks like this:
  38. .. sourcecode:: http
  39. HTTP/1.1 200 OK
  40. Content-Type: application/json
  41. {"status":"Pushing..."}
  42. {"status":"Pushing", "progress":"1/? (n/a)"}
  43. {"error":"Invalid..."}
  44. ...
  45. docker v0.3.4 8d73740_
  46. HTTP/1.1 200 OK
  47. Content-Type: application/vnd.docker.raw-stream
  48. {{ STREAM }}
  49. :query registry: the registry you wan to push, optional
  50. :statuscode 200: no error
  51. :statuscode 404: no such image
  52. :statuscode 500: server error
  53. Tag an image into a repository
  54. ******************************
  55. .. http:post:: /images/(name)/tag
  56. Tag the image ``name`` into a repository
  57. **Example request**:
  58. .. sourcecode:: http
  59. POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
  60. **Example response**:
  61. .. sourcecode:: http
  62. HTTP/1.1 200 OK
  63. :query repo: The repository to tag in
  64. :query force: 1/True/true or 0/False/false, default false
  65. :statuscode 200: no error
  66. :statuscode 400: bad parameter
  67. :statuscode 404: no such image
  68. :statuscode 500: server error
  69. Remove an image
  70. ***************
  71. .. http:delete:: /images/(name)
  72. Remove the image ``name`` from the filesystem
  73. **Example request**:
  74. .. sourcecode:: http
  75. DELETE /images/test HTTP/1.1
  76. **Example response**:
  77. .. sourcecode:: http
  78. HTTP/1.1 204 OK
  79. :statuscode 204: no error
  80. :statuscode 404: no such image
  81. :statuscode 500: server error
  82. Search images
  83. *************
  84. .. http:get:: /images/search
  85. Search for an image in the docker index
  86. **Example request**:
  87. .. sourcecode:: http
  88. GET /images/search?term=sshd HTTP/1.1
  89. **Example response**:
  90. .. sourcecode:: http
  91. HTTP/1.1 200 OK
  92. Content-Type: application/json
  93. [
  94. {
  95. "Name":"cespare/sshd",
  96. "Description":""
  97. },
  98. {
  99. "Name":"johnfuller/sshd",
  100. "Description":""
  101. },
  102. {
  103. "Name":"dhrp/mongodb-sshd",
  104. "Description":""
  105. }
  106. ]
  107. :query term: term to search
  108. :statuscode 200: no error
  109. :statuscode 500: server error
  110. 3.3 Misc
  111. --------
  112. Build an image from Dockerfile via stdin
  113. ****************************************
  114. .. http:post:: /build
  115. Build an image from Dockerfile via stdin
  116. **Example request**:
  117. .. sourcecode:: http
  118. POST /build HTTP/1.1
  119. {{ STREAM }}
  120. **Example response**:
  121. .. sourcecode:: http
  122. HTTP/1.1 200 OK
  123. {{ STREAM }}
  124. :query t: tag to be applied to the resulting image in case of success
  125. :query remote: URL to be fetch. Either a single Dockerfile or a Git repository
  126. :statuscode 200: no error
  127. :statuscode 500: server error
  128. Get default username and email
  129. ******************************
  130. .. http:get:: /auth
  131. Get the default username and email
  132. **Example request**:
  133. .. sourcecode:: http
  134. GET /auth HTTP/1.1
  135. **Example response**:
  136. .. sourcecode:: http
  137. HTTP/1.1 200 OK
  138. Content-Type: application/json
  139. {
  140. "username":"hannibal",
  141. "email":"hannibal@a-team.com"
  142. }
  143. :statuscode 200: no error
  144. :statuscode 500: server error
  145. Set auth configuration
  146. **********************
  147. .. http:post:: /auth
  148. Get the default username and email
  149. **Example request**:
  150. .. sourcecode:: http
  151. POST /auth HTTP/1.1
  152. Content-Type: application/json
  153. {
  154. "username":"hannibal",
  155. "password:"xxxx",
  156. "email":"hannibal@a-team.com"
  157. }
  158. **Example response**:
  159. .. sourcecode:: http
  160. HTTP/1.1 200 OK
  161. :statuscode 200: no error
  162. :statuscode 204: no error
  163. :statuscode 500: server error
  164. Display system-wide information
  165. *******************************
  166. .. http:get:: /info
  167. Display system-wide information
  168. **Example request**:
  169. .. sourcecode:: http
  170. GET /info HTTP/1.1
  171. **Example response**:
  172. .. sourcecode:: http
  173. HTTP/1.1 200 OK
  174. Content-Type: application/json
  175. {
  176. "Containers":11,
  177. "Images":16,
  178. "Debug":false,
  179. "NFd": 11,
  180. "NGoroutines":21,
  181. "MemoryLimit":true,
  182. "SwapLimit":false
  183. }
  184. :statuscode 200: no error
  185. :statuscode 500: server error
  186. Show the docker version information
  187. ***********************************
  188. .. http:get:: /version
  189. Show the docker version information
  190. **Example request**:
  191. .. sourcecode:: http
  192. GET /version HTTP/1.1
  193. **Example response**:
  194. .. sourcecode:: http
  195. HTTP/1.1 200 OK
  196. Content-Type: application/json
  197. {
  198. "Version":"0.2.2",
  199. "GitCommit":"5a2a5cc+CHANGES",
  200. "GoVersion":"go1.0.3"
  201. }
  202. :statuscode 200: no error
  203. :statuscode 500: server error
  204. Create a new image from a container's changes
  205. *********************************************
  206. .. http:post:: /commit
  207. Create a new image from a container's changes
  208. **Example request**:
  209. .. sourcecode:: http
  210. POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  211. **Example response**:
  212. .. sourcecode:: http
  213. HTTP/1.1 201 OK
  214. Content-Type: application/vnd.docker.raw-stream
  215. {"Id":"596069db4bf5"}
  216. Initial version
  217. .. _a8ae398: https://github.com/dotcloud/docker/commit/a8ae398bf52e97148ee7bd0d5868de2e15bd297f
  218. .. _8d73740: https://github.com/dotcloud/docker/commit/8d73740343778651c09160cde9661f5f387b36f4
  219. ==================================
  220. Docker Remote API Client Libraries
  221. ==================================
  222. These libraries have been not tested by the Docker Maintainers for
  223. compatibility. Please file issues with the library owners. If you
  224. find more library implementations, please list them in Docker doc bugs
  225. and we will add the libraries here.
  226. +----------------------+----------------+--------------------------------------------+
  227. | Language/Framework | Name | Repository |
  228. +======================+================+============================================+
  229. | Python | docker-py | https://github.com/dotcloud/docker-py |
  230. +----------------------+----------------+--------------------------------------------+
  231. | Ruby | docker-ruby | https://github.com/ActiveState/docker-ruby |
  232. +----------------------+----------------+--------------------------------------------+
  233. | Ruby | docker-client | https://github.com/geku/docker-client |
  234. +----------------------+----------------+--------------------------------------------+
  235. | Javascript | docker-js | https://github.com/dgoujard/docker-js |
  236. +----------------------+----------------+--------------------------------------------+
  237. | Javascript (Angular) | dockerui | https://github.com/crosbymichael/dockerui |
  238. | **WebUI** | | |
  239. +----------------------+----------------+--------------------------------------------+