registry_api.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. 1. Brief introduction
  8. =====================
  9. - This is the REST API for the Docker Registry
  10. - It stores the images and the graph for a set of repositories
  11. - It does not have user accounts data
  12. - It has no notion of user accounts or authorization
  13. - It delegates authentication and authorization to the Index Auth service using tokens
  14. - It supports different storage backends (S3, cloud files, local FS)
  15. - It doesn’t have a local database
  16. - It will be open-sourced at some point
  17. We expect that there will be multiple registries out there. To help to grasp
  18. 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``
  31. and ``registryput``, wrapping access to the local filesystem (and optionally
  32. doing consistency checks). Authentication and authorization are then delegated
  33. to SSH (e.g. with public keys).
  34. 2. Endpoints
  35. ============
  36. 2.1 Images
  37. ----------
  38. Layer
  39. *****
  40. .. http:get:: /v1/images/(image_id)/layer
  41. get image layer for a given ``image_id``
  42. **Example Request**:
  43. .. sourcecode:: http
  44. GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
  45. Host: registry-1.docker.io
  46. Accept: application/json
  47. Content-Type: application/json
  48. Authorization: Token signature=123abc,repository="foo/bar",access=read
  49. :parameter image_id: the id for the layer you want to get
  50. **Example Response**:
  51. .. sourcecode:: http
  52. HTTP/1.1 200
  53. Vary: Accept
  54. X-Docker-Registry-Version: 0.6.0
  55. Cookie: (Cookie provided by the Registry)
  56. {layer binary data stream}
  57. :statuscode 200: OK
  58. :statuscode 401: Requires authorization
  59. :statuscode 404: Image not found
  60. .. http:put:: /v1/images/(image_id)/layer
  61. put image layer for a given ``image_id``
  62. **Example Request**:
  63. .. sourcecode:: http
  64. PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
  65. Host: registry-1.docker.io
  66. Transfer-Encoding: chunked
  67. Authorization: Token signature=123abc,repository="foo/bar",access=write
  68. {layer binary data stream}
  69. :parameter image_id: the id for the layer you want to get
  70. **Example Response**:
  71. .. sourcecode:: http
  72. HTTP/1.1 200
  73. Vary: Accept
  74. Content-Type: application/json
  75. X-Docker-Registry-Version: 0.6.0
  76. ""
  77. :statuscode 200: OK
  78. :statuscode 401: Requires authorization
  79. :statuscode 404: Image not found
  80. Image
  81. *****
  82. .. http:put:: /v1/images/(image_id)/json
  83. put image for a given ``image_id``
  84. **Example Request**:
  85. .. sourcecode:: http
  86. PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
  87. Host: registry-1.docker.io
  88. Accept: application/json
  89. Content-Type: application/json
  90. Cookie: (Cookie provided by the Registry)
  91. {
  92. id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
  93. parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
  94. created: "2013-04-30T17:46:10.843673+03:00",
  95. container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
  96. container_config: {
  97. Hostname: "host-test",
  98. User: "",
  99. Memory: 0,
  100. MemorySwap: 0,
  101. AttachStdin: false,
  102. AttachStdout: false,
  103. AttachStderr: false,
  104. PortSpecs: null,
  105. Tty: false,
  106. OpenStdin: false,
  107. StdinOnce: false,
  108. Env: null,
  109. Cmd: [
  110. "/bin/bash",
  111. "-c",
  112. "apt-get -q -yy -f install libevent-dev"
  113. ],
  114. Dns: null,
  115. Image: "imagename/blah",
  116. Volumes: { },
  117. VolumesFrom: ""
  118. },
  119. docker_version: "0.1.7"
  120. }
  121. :parameter image_id: the id for the layer you want to get
  122. **Example Response**:
  123. .. sourcecode:: http
  124. HTTP/1.1 200
  125. Vary: Accept
  126. Content-Type: application/json
  127. X-Docker-Registry-Version: 0.6.0
  128. ""
  129. :statuscode 200: OK
  130. :statuscode 401: Requires authorization
  131. .. http:get:: /v1/images/(image_id)/json
  132. get image for a given ``image_id``
  133. **Example Request**:
  134. .. sourcecode:: http
  135. GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
  136. Host: registry-1.docker.io
  137. Accept: application/json
  138. Content-Type: application/json
  139. Cookie: (Cookie provided by the Registry)
  140. :parameter image_id: the id for the layer you want to get
  141. **Example Response**:
  142. .. sourcecode:: http
  143. HTTP/1.1 200
  144. Vary: Accept
  145. Content-Type: application/json
  146. X-Docker-Registry-Version: 0.6.0
  147. X-Docker-Size: 456789
  148. X-Docker-Checksum: b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087
  149. {
  150. id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
  151. parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
  152. created: "2013-04-30T17:46:10.843673+03:00",
  153. container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
  154. container_config: {
  155. Hostname: "host-test",
  156. User: "",
  157. Memory: 0,
  158. MemorySwap: 0,
  159. AttachStdin: false,
  160. AttachStdout: false,
  161. AttachStderr: false,
  162. PortSpecs: null,
  163. Tty: false,
  164. OpenStdin: false,
  165. StdinOnce: false,
  166. Env: null,
  167. Cmd: [
  168. "/bin/bash",
  169. "-c",
  170. "apt-get -q -yy -f install libevent-dev"
  171. ],
  172. Dns: null,
  173. Image: "imagename/blah",
  174. Volumes: { },
  175. VolumesFrom: ""
  176. },
  177. docker_version: "0.1.7"
  178. }
  179. :statuscode 200: OK
  180. :statuscode 401: Requires authorization
  181. :statuscode 404: Image not found
  182. Ancestry
  183. ********
  184. .. http:get:: /v1/images/(image_id)/ancestry
  185. get ancestry for an image given an ``image_id``
  186. **Example Request**:
  187. .. sourcecode:: http
  188. GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/ancestry HTTP/1.1
  189. Host: registry-1.docker.io
  190. Accept: application/json
  191. Content-Type: application/json
  192. Cookie: (Cookie provided by the Registry)
  193. :parameter image_id: the id for the layer you want to get
  194. **Example Response**:
  195. .. sourcecode:: http
  196. HTTP/1.1 200
  197. Vary: Accept
  198. Content-Type: application/json
  199. X-Docker-Registry-Version: 0.6.0
  200. ["088b4502f51920fbd9b7c503e87c7a2c05aa3adc3d35e79c031fa126b403200f",
  201. "aeee63968d87c7da4a5cf5d2be6bee4e21bc226fd62273d180a49c96c62e4543",
  202. "bfa4c5326bc764280b0863b46a4b20d940bc1897ef9c1dfec060604bdc383280",
  203. "6ab5893c6927c15a15665191f2c6cf751f5056d8b95ceee32e43c5e8a3648544"]
  204. :statuscode 200: OK
  205. :statuscode 401: Requires authorization
  206. :statuscode 404: Image not found
  207. 2.2 Tags
  208. --------
  209. .. http:get:: /v1/repositories/(namespace)/(repository)/tags
  210. get all of the tags for the given repo.
  211. **Example Request**:
  212. .. sourcecode:: http
  213. GET /v1/repositories/foo/bar/tags HTTP/1.1
  214. Host: registry-1.docker.io
  215. Accept: application/json
  216. Content-Type: application/json
  217. X-Docker-Registry-Version: 0.6.0
  218. Cookie: (Cookie provided by the Registry)
  219. :parameter namespace: namespace for the repo
  220. :parameter repository: name for the repo
  221. **Example Response**:
  222. .. sourcecode:: http
  223. HTTP/1.1 200
  224. Vary: Accept
  225. Content-Type: application/json
  226. X-Docker-Registry-Version: 0.6.0
  227. {
  228. "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
  229. "0.1.1": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"
  230. }
  231. :statuscode 200: OK
  232. :statuscode 401: Requires authorization
  233. :statuscode 404: Repository not found
  234. .. http:get:: /v1/repositories/(namespace)/(repository)/tags/(tag)
  235. get a tag for the given repo.
  236. **Example Request**:
  237. .. sourcecode:: http
  238. GET /v1/repositories/foo/bar/tags/latest HTTP/1.1
  239. Host: registry-1.docker.io
  240. Accept: application/json
  241. Content-Type: application/json
  242. X-Docker-Registry-Version: 0.6.0
  243. Cookie: (Cookie provided by the Registry)
  244. :parameter namespace: namespace for the repo
  245. :parameter repository: name for the repo
  246. :parameter tag: name of tag you want to get
  247. **Example Response**:
  248. .. sourcecode:: http
  249. HTTP/1.1 200
  250. Vary: Accept
  251. Content-Type: application/json
  252. X-Docker-Registry-Version: 0.6.0
  253. "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
  254. :statuscode 200: OK
  255. :statuscode 401: Requires authorization
  256. :statuscode 404: Tag not found
  257. .. http:delete:: /v1/repositories/(namespace)/(repository)/tags/(tag)
  258. delete the tag for the repo
  259. **Example Request**:
  260. .. sourcecode:: http
  261. DELETE /v1/repositories/foo/bar/tags/latest HTTP/1.1
  262. Host: registry-1.docker.io
  263. Accept: application/json
  264. Content-Type: application/json
  265. Cookie: (Cookie provided by the Registry)
  266. :parameter namespace: namespace for the repo
  267. :parameter repository: name for the repo
  268. :parameter tag: name of tag you want to delete
  269. **Example Response**:
  270. .. sourcecode:: http
  271. HTTP/1.1 200
  272. Vary: Accept
  273. Content-Type: application/json
  274. X-Docker-Registry-Version: 0.6.0
  275. ""
  276. :statuscode 200: OK
  277. :statuscode 401: Requires authorization
  278. :statuscode 404: Tag not found
  279. .. http:put:: /v1/repositories/(namespace)/(repository)/tags/(tag)
  280. put a tag for the given repo.
  281. **Example Request**:
  282. .. sourcecode:: http
  283. PUT /v1/repositories/foo/bar/tags/latest HTTP/1.1
  284. Host: registry-1.docker.io
  285. Accept: application/json
  286. Content-Type: application/json
  287. Cookie: (Cookie provided by the Registry)
  288. "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
  289. :parameter namespace: namespace for the repo
  290. :parameter repository: name for the repo
  291. :parameter tag: name of tag you want to add
  292. **Example Response**:
  293. .. sourcecode:: http
  294. HTTP/1.1 200
  295. Vary: Accept
  296. Content-Type: application/json
  297. X-Docker-Registry-Version: 0.6.0
  298. ""
  299. :statuscode 200: OK
  300. :statuscode 400: Invalid data
  301. :statuscode 401: Requires authorization
  302. :statuscode 404: Image not found
  303. 2.3 Repositories
  304. ----------------
  305. .. http:delete:: /v1/repositories/(namespace)/(repository)/
  306. delete a repository
  307. **Example Request**:
  308. .. sourcecode:: http
  309. DELETE /v1/repositories/foo/bar/ HTTP/1.1
  310. Host: registry-1.docker.io
  311. Accept: application/json
  312. Content-Type: application/json
  313. Cookie: (Cookie provided by the Registry)
  314. ""
  315. :parameter namespace: namespace for the repo
  316. :parameter repository: name for the repo
  317. **Example Response**:
  318. .. sourcecode:: http
  319. HTTP/1.1 200
  320. Vary: Accept
  321. Content-Type: application/json
  322. X-Docker-Registry-Version: 0.6.0
  323. ""
  324. :statuscode 200: OK
  325. :statuscode 401: Requires authorization
  326. :statuscode 404: Repository not found
  327. 2.4 Status
  328. ----------
  329. .. http:get:: /v1/_ping
  330. Check status of the registry. This endpoint is also used to determine if
  331. the registry supports SSL.
  332. **Example Request**:
  333. .. sourcecode:: http
  334. GET /v1/_ping HTTP/1.1
  335. Host: registry-1.docker.io
  336. Accept: application/json
  337. Content-Type: application/json
  338. ""
  339. **Example Response**:
  340. .. sourcecode:: http
  341. HTTP/1.1 200
  342. Vary: Accept
  343. Content-Type: application/json
  344. X-Docker-Registry-Version: 0.6.0
  345. ""
  346. :statuscode 200: OK
  347. 3 Authorization
  348. ===============
  349. This is where we describe the authorization process, including the tokens and cookies.
  350. TODO: add more info.