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