registry_api.rst 15 KB

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