registry_api.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. :title: Registry API
  2. :description: API Documentation for Docker Registry
  3. :keywords: API, Docker, index, registry, REST, documentation
  4. ===================
  5. Docker Registry API
  6. ===================
  7. .. contents:: Table of Contents
  8. 1. Brief introduction
  9. =====================
  10. - This is the REST API for the Docker Registry
  11. - It stores the images and the graph for a set of repositories
  12. - It does not have user accounts data
  13. - It has no notion of user accounts or authorization
  14. - It delegates authentication and authorization to the Index Auth service using tokens
  15. - It supports different storage backends (S3, cloud files, local FS)
  16. - It doesn’t have a local database
  17. - It will be open-sourced at some point
  18. We expect that there will be multiple registries out there. To help to grasp the context, here are some examples of registries:
  19. - **sponsor registry**: such a registry is provided by a third-party hosting infrastructure as a convenience for their customers and the docker community as a whole. Its costs are supported by the third party, but the management and operation of the registry are supported by dotCloud. It features read/write access, and delegates authentication and authorization to the Index.
  20. - **mirror registry**: such a registry is provided by a third-party hosting infrastructure but is targeted at their customers only. Some mechanism (unspecified to date) ensures that public images are pulled from a sponsor registry to the mirror registry, to make sure that the customers of the third-party provider can “docker pull” those images locally.
  21. - **vendor registry**: such a registry is provided by a software vendor, who wants to distribute docker images. It would be operated and managed by the vendor. Only users authorized by the vendor would be able to get write access. Some images would be public (accessible for anyone), others private (accessible only for authorized users). Authentication and authorization would be delegated to the Index. The goal of vendor registries is to let someone do “docker pull basho/riak1.3” and automatically push from the vendor registry (instead of a sponsor registry); i.e. get all the convenience of a sponsor registry, while retaining control on the asset distribution.
  22. - **private registry**: such a registry is located behind a firewall, or protected by an additional security layer (HTTP authorization, SSL client-side certificates, IP address authorization...). The registry is operated by a private entity, outside of dotCloud’s control. It can optionally delegate additional authorization to the Index, but it is not mandatory.
  23. .. note::
  24. Mirror registries and private registries which do not use the Index don’t even need to run the registry code. They can be implemented by any kind of transport implementing HTTP GET and PUT. Read-only registries can be powered by a simple static HTTP server.
  25. .. note::
  26. The latter implies that while HTTP is the protocol of choice for a registry, multiple schemes are possible (and in some cases, trivial):
  27. - HTTP with GET (and PUT for read-write registries);
  28. - local mount point;
  29. - remote docker addressed through SSH.
  30. The latter would only require two new commands in docker, e.g. “registryget” and “registryput”, wrapping access to the local filesystem (and optionally doing consistency checks). Authentication and authorization are then delegated to SSH (e.g. with public keys).
  31. 2. Endpoints
  32. ============
  33. 2.1 Images
  34. ----------
  35. Layer
  36. *****
  37. .. http:get:: /v1/images/(image_id)/layer
  38. get image layer for a given ``image_id``
  39. **Example Request**:
  40. .. sourcecode:: http
  41. GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
  42. Host: registry-1.docker.io
  43. Accept: application/json
  44. Content-Type: application/json
  45. Authorization: Token akmklmasadalkmsdfgsdgdge33
  46. :parameter image_id: the id for the layer you want to get
  47. **Example Response**:
  48. .. sourcecode:: http
  49. HTTP/1.1 200
  50. Vary: Accept
  51. Content-Type: application/json
  52. Cookie: (Cookie provided by the Registry)
  53. {
  54. id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
  55. parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
  56. created: "2013-04-30T17:46:10.843673+03:00",
  57. container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
  58. container_config: {
  59. Hostname: "host-test",
  60. User: "",
  61. Memory: 0,
  62. MemorySwap: 0,
  63. AttachStdin: false,
  64. AttachStdout: false,
  65. AttachStderr: false,
  66. PortSpecs: null,
  67. Tty: false,
  68. OpenStdin: false,
  69. StdinOnce: false,
  70. Env: null,
  71. Cmd: [
  72. "/bin/bash",
  73. "-c",
  74. "apt-get -q -yy -f install libevent-dev"
  75. ],
  76. Dns: null,
  77. Image: "imagename/blah",
  78. Volumes: { },
  79. VolumesFrom: ""
  80. },
  81. docker_version: "0.1.7"
  82. }
  83. :statuscode 200: OK
  84. :statuscode 401: Requires authorization
  85. :statuscode 404: Image not found
  86. .. http:put:: /v1/images/(image_id)/layer
  87. put image layer for a given ``image_id``
  88. **Example Request**:
  89. .. sourcecode:: http
  90. PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
  91. Host: registry-1.docker.io
  92. Accept: application/json
  93. Content-Type: application/json
  94. Authorization: Token akmklmasadalkmsdfgsdgdge33
  95. {
  96. id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
  97. parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
  98. created: "2013-04-30T17:46:10.843673+03:00",
  99. container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
  100. container_config: {
  101. Hostname: "host-test",
  102. User: "",
  103. Memory: 0,
  104. MemorySwap: 0,
  105. AttachStdin: false,
  106. AttachStdout: false,
  107. AttachStderr: false,
  108. PortSpecs: null,
  109. Tty: false,
  110. OpenStdin: false,
  111. StdinOnce: false,
  112. Env: null,
  113. Cmd: [
  114. "/bin/bash",
  115. "-c",
  116. "apt-get -q -yy -f install libevent-dev"
  117. ],
  118. Dns: null,
  119. Image: "imagename/blah",
  120. Volumes: { },
  121. VolumesFrom: ""
  122. },
  123. docker_version: "0.1.7"
  124. }
  125. :parameter image_id: the id for the layer you want to get
  126. **Example Response**:
  127. .. sourcecode:: http
  128. HTTP/1.1 200
  129. Vary: Accept
  130. Content-Type: application/json
  131. ""
  132. :statuscode 200: OK
  133. :statuscode 401: Requires authorization
  134. :statuscode 404: Image not found
  135. Image
  136. *****
  137. .. http:put:: /v1/images/(image_id)/json
  138. put image for a given ``image_id``
  139. **Example Request**:
  140. .. sourcecode:: http
  141. PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
  142. Host: registry-1.docker.io
  143. Accept: application/json
  144. Content-Type: application/json
  145. Cookie: (Cookie provided by the Registry)
  146. {
  147. “id”: “088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c”,
  148. “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
  149. }
  150. :parameter image_id: the id for the layer you want to get
  151. **Example Response**:
  152. .. sourcecode:: http
  153. HTTP/1.1 200
  154. Vary: Accept
  155. Content-Type: application/json
  156. ""
  157. :statuscode 200: OK
  158. :statuscode 401: Requires authorization
  159. .. http:get:: /v1/images/(image_id)/json
  160. get image for a given ``image_id``
  161. **Example Request**:
  162. .. sourcecode:: http
  163. GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
  164. Host: registry-1.docker.io
  165. Accept: application/json
  166. Content-Type: application/json
  167. Cookie: (Cookie provided by the Registry)
  168. :parameter image_id: the id for the layer you want to get
  169. **Example Response**:
  170. .. sourcecode:: http
  171. HTTP/1.1 200
  172. Vary: Accept
  173. Content-Type: application/json
  174. {
  175. “id”: “088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c”,
  176. “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
  177. }
  178. :statuscode 200: OK
  179. :statuscode 401: Requires authorization
  180. :statuscode 404: Image not found
  181. Ancestry
  182. ********
  183. .. http:get:: /v1/images/(image_id)/ancestry
  184. get ancestry for an image given an ``image_id``
  185. **Example Request**:
  186. .. sourcecode:: http
  187. GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/ancestry HTTP/1.1
  188. Host: registry-1.docker.io
  189. Accept: application/json
  190. Content-Type: application/json
  191. Cookie: (Cookie provided by the Registry)
  192. :parameter image_id: the id for the layer you want to get
  193. **Example Response**:
  194. .. sourcecode:: http
  195. HTTP/1.1 200
  196. Vary: Accept
  197. Content-Type: application/json
  198. ["088b4502f51920fbd9b7c503e87c7a2c05aa3adc3d35e79c031fa126b403200f",
  199. "aeee63968d87c7da4a5cf5d2be6bee4e21bc226fd62273d180a49c96c62e4543",
  200. "bfa4c5326bc764280b0863b46a4b20d940bc1897ef9c1dfec060604bdc383280",
  201. "6ab5893c6927c15a15665191f2c6cf751f5056d8b95ceee32e43c5e8a3648544"]
  202. :statuscode 200: OK
  203. :statuscode 401: Requires authorization
  204. :statuscode 404: Image not found
  205. 2.2 Tags
  206. --------
  207. .. http:get:: /v1/repositories/(namespace)/(repository)/tags
  208. get all of the tags for the given repo.
  209. **Example Request**:
  210. .. sourcecode:: http
  211. GET /v1/repositories/foo/bar/tags HTTP/1.1
  212. Host: registry-1.docker.io
  213. Accept: application/json
  214. Content-Type: application/json
  215. Cookie: (Cookie provided by the Registry)
  216. :parameter namespace: namespace for the repo
  217. :parameter repository: name for the repo
  218. **Example Response**:
  219. .. sourcecode:: http
  220. HTTP/1.1 200
  221. Vary: Accept
  222. Content-Type: application/json
  223. {
  224. "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
  225. “0.1.1”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
  226. }
  227. :statuscode 200: OK
  228. :statuscode 401: Requires authorization
  229. :statuscode 404: Repository not found
  230. .. http:get:: /v1/repositories/(namespace)/(repository)/tags/(tag)
  231. get a tag for the given repo.
  232. **Example Request**:
  233. .. sourcecode:: http
  234. GET /v1/repositories/foo/bar/tags/latest HTTP/1.1
  235. Host: registry-1.docker.io
  236. Accept: application/json
  237. Content-Type: application/json
  238. Cookie: (Cookie provided by the Registry)
  239. :parameter namespace: namespace for the repo
  240. :parameter repository: name for the repo
  241. :parameter tag: name of tag you want to get
  242. **Example Response**:
  243. .. sourcecode:: http
  244. HTTP/1.1 200
  245. Vary: Accept
  246. Content-Type: application/json
  247. "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
  248. :statuscode 200: OK
  249. :statuscode 401: Requires authorization
  250. :statuscode 404: Tag not found
  251. .. http:delete:: /v1/repositories/(namespace)/(repository)/tags/(tag)
  252. delete the tag for the repo
  253. **Example Request**:
  254. .. sourcecode:: http
  255. DELETE /v1/repositories/foo/bar/tags/latest HTTP/1.1
  256. Host: registry-1.docker.io
  257. Accept: application/json
  258. Content-Type: application/json
  259. Cookie: (Cookie provided by the Registry)
  260. :parameter namespace: namespace for the repo
  261. :parameter repository: name for the repo
  262. :parameter tag: name of tag you want to delete
  263. **Example Response**:
  264. .. sourcecode:: http
  265. HTTP/1.1 200
  266. Vary: Accept
  267. Content-Type: application/json
  268. ""
  269. :statuscode 200: OK
  270. :statuscode 401: Requires authorization
  271. :statuscode 404: Tag not found
  272. .. http:put:: /v1/repositories/(namespace)/(repository)/tags/(tag)
  273. put a tag for the given repo.
  274. **Example Request**:
  275. .. sourcecode:: http
  276. PUT /v1/repositories/foo/bar/tags/latest HTTP/1.1
  277. Host: registry-1.docker.io
  278. Accept: application/json
  279. Content-Type: application/json
  280. Cookie: (Cookie provided by the Registry)
  281. “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”
  282. :parameter namespace: namespace for the repo
  283. :parameter repository: name for the repo
  284. :parameter tag: name of tag you want to add
  285. **Example Response**:
  286. .. sourcecode:: http
  287. HTTP/1.1 200
  288. Vary: Accept
  289. Content-Type: application/json
  290. ""
  291. :statuscode 200: OK
  292. :statuscode 400: Invalid data
  293. :statuscode 401: Requires authorization
  294. :statuscode 404: Image not found
  295. 2.3 Repositories
  296. ----------------
  297. .. http:delete:: /v1/repositories/(namespace)/(repository)/
  298. delete a repository
  299. **Example Request**:
  300. .. sourcecode:: http
  301. DELETE /v1/repositories/foo/bar/ HTTP/1.1
  302. Host: registry-1.docker.io
  303. Accept: application/json
  304. Content-Type: application/json
  305. Cookie: (Cookie provided by the Registry)
  306. ""
  307. :parameter namespace: namespace for the repo
  308. :parameter repository: name for the repo
  309. **Example Response**:
  310. .. sourcecode:: http
  311. HTTP/1.1 200
  312. Vary: Accept
  313. Content-Type: application/json
  314. ""
  315. :statuscode 200: OK
  316. :statuscode 401: Requires authorization
  317. :statuscode 404: Repository not found
  318. 3.0 Authorization
  319. =================
  320. This is where we describe the authorization process, including the tokens and cookies.
  321. TODO: add more info.