Browse code

seperated the registry and index API's into their own docs

seperated the registry and index API's into their own docs and merged
in the index search api into the index api. Also renamed the original
registry api to registry_index_spec.

Ken Cochrane authored on 2013/06/08 02:42:52
Showing 5 changed files
... ...
@@ -10,8 +10,9 @@ This following :
10 10
 .. toctree::
11 11
   :maxdepth: 3
12 12
 
13
+  registry_index_spec
13 14
   registry_api
14
-  index_search_api
15
+  index_api
15 16
   docker_remote_api
16 17
 
17 18
 
18 19
new file mode 100644
... ...
@@ -0,0 +1,553 @@
0
+:title: Index API
1
+:description: API Documentation for Docker Index
2
+:keywords: API, Docker, index, REST, documentation
3
+
4
+=================
5
+Docker Index API
6
+=================
7
+
8
+.. contents:: Table of Contents
9
+
10
+1. Brief introduction
11
+=====================
12
+
13
+- This is the REST API for the Docker index
14
+- Authorization is done with basic auth over SSL
15
+- Not all commands require authentication, only those noted as such.
16
+
17
+2. Endpoints
18
+============
19
+
20
+2.1 Repository
21
+^^^^^^^^^^^^^^
22
+
23
+Repositories
24
+*************
25
+
26
+User Repo
27
+~~~~~~~~~
28
+
29
+.. http:put:: /v1/repositories/(namespace)/(repo_name)/
30
+
31
+    Create a user repository with the given ``namespace`` and ``repo_name``.
32
+
33
+    **Example Request**:
34
+
35
+    .. sourcecode:: http
36
+
37
+        PUT /v1/repositories/foo/bar/ HTTP/1.1
38
+        Host: index.docker.io
39
+        Accept: application/json
40
+        Content-Type: application/json
41
+        Authorization: Basic akmklmasadalkm==
42
+        X-Docker-Token: true
43
+
44
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
45
+
46
+    :parameter namespace: the namespace for the repo
47
+    :parameter repo_name: the name for the repo
48
+
49
+    **Example Response**:
50
+
51
+    .. sourcecode:: http
52
+
53
+        HTTP/1.1 200
54
+        Vary: Accept
55
+        Content-Type: application/json
56
+        WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
57
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
58
+
59
+        ""
60
+
61
+    :statuscode 200: Created
62
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
63
+    :statuscode 401: Unauthorized
64
+    :statuscode 403: Account is not Active
65
+
66
+
67
+.. http:delete:: /v1/repositories/(namespace)/(repo_name)/
68
+
69
+    Delete a user repository with the given ``namespace`` and ``repo_name``.
70
+
71
+    **Example Request**:
72
+
73
+    .. sourcecode:: http
74
+
75
+        DELETE /v1/repositories/foo/bar/ HTTP/1.1
76
+        Host: index.docker.io
77
+        Accept: application/json
78
+        Content-Type: application/json
79
+        Authorization: Basic akmklmasadalkm==
80
+        X-Docker-Token: true
81
+
82
+        ""
83
+
84
+    :parameter namespace: the namespace for the repo
85
+    :parameter repo_name: the name for the repo
86
+
87
+    **Example Response**:
88
+
89
+    .. sourcecode:: http
90
+
91
+        HTTP/1.1 202
92
+        Vary: Accept
93
+        Content-Type: application/json
94
+        WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=delete
95
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
96
+
97
+        ""
98
+
99
+    :statuscode 200: Deleted
100
+    :statuscode 202: Accepted
101
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
102
+    :statuscode 401: Unauthorized
103
+    :statuscode 403: Account is not Active
104
+
105
+Library Repo
106
+~~~~~~~~~~~~
107
+
108
+.. http:put:: /v1/repositories/(repo_name)/
109
+
110
+    Create a library repository with the given ``repo_name``.
111
+    This is a restricted feature only available to docker admins.
112
+    
113
+    When namespace is missing, it is assumed to be ``library``
114
+
115
+    **Example Request**:
116
+
117
+    .. sourcecode:: http
118
+
119
+        PUT /v1/repositories/foobar/ HTTP/1.1
120
+        Host: index.docker.io
121
+        Accept: application/json
122
+        Content-Type: application/json
123
+        Authorization: Basic akmklmasadalkm==
124
+        X-Docker-Token: true
125
+
126
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
127
+
128
+    :parameter repo_name:  the library name for the repo
129
+
130
+    **Example Response**:
131
+
132
+    .. sourcecode:: http
133
+
134
+        HTTP/1.1 200
135
+        Vary: Accept
136
+        Content-Type: application/json
137
+        WWW-Authenticate: Token signature=123abc,repository=”library/foobar”,access=write
138
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
139
+
140
+        ""
141
+
142
+    :statuscode 200: Created
143
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
144
+    :statuscode 401: Unauthorized
145
+    :statuscode 403: Account is not Active
146
+
147
+.. http:delete:: /v1/repositories/(repo_name)/
148
+
149
+    Delete a library repository with the given ``repo_name``.
150
+    This is a restricted feature only available to docker admins.
151
+    
152
+    When namespace is missing, it is assumed to be ``library``
153
+
154
+    **Example Request**:
155
+
156
+    .. sourcecode:: http
157
+
158
+        DELETE /v1/repositories/foobar/ HTTP/1.1
159
+        Host: index.docker.io
160
+        Accept: application/json
161
+        Content-Type: application/json
162
+        Authorization: Basic akmklmasadalkm==
163
+        X-Docker-Token: true
164
+
165
+        ""
166
+
167
+    :parameter repo_name:  the library name for the repo
168
+
169
+    **Example Response**:
170
+
171
+    .. sourcecode:: http
172
+
173
+        HTTP/1.1 202
174
+        Vary: Accept
175
+        Content-Type: application/json
176
+        WWW-Authenticate: Token signature=123abc,repository=”library/foobar”,access=delete
177
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
178
+
179
+        ""
180
+
181
+    :statuscode 200: Deleted
182
+    :statuscode 202: Accepted
183
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
184
+    :statuscode 401: Unauthorized
185
+    :statuscode 403: Account is not Active
186
+
187
+Repository Images
188
+*****************
189
+
190
+User Repo Images
191
+~~~~~~~~~~~~~~~~
192
+
193
+.. http:put:: /v1/repositories/(namespace)/(repo_name)/images
194
+
195
+    Update the images for a user repo.
196
+
197
+    **Example Request**:
198
+
199
+    .. sourcecode:: http
200
+
201
+        PUT /v1/repositories/foo/bar/images HTTP/1.1
202
+        Host: index.docker.io
203
+        Accept: application/json
204
+        Content-Type: application/json
205
+        Authorization: Basic akmklmasadalkm==
206
+
207
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
208
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
209
+
210
+    :parameter namespace: the namespace for the repo
211
+    :parameter repo_name: the name for the repo
212
+
213
+    **Example Response**:
214
+
215
+    .. sourcecode:: http
216
+
217
+        HTTP/1.1 204
218
+        Vary: Accept
219
+        Content-Type: application/json
220
+
221
+        ""
222
+
223
+    :statuscode 204: Created
224
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
225
+    :statuscode 401: Unauthorized
226
+    :statuscode 403: Account is not Active or permission denied
227
+
228
+
229
+.. http:get:: /v1/repositories/(namespace)/(repo_name)/images
230
+
231
+    get the images for a user repo.
232
+
233
+    **Example Request**:
234
+
235
+    .. sourcecode:: http
236
+
237
+        GET /v1/repositories/foo/bar/images HTTP/1.1
238
+        Host: index.docker.io
239
+        Accept: application/json
240
+
241
+    :parameter namespace: the namespace for the repo
242
+    :parameter repo_name: the name for the repo
243
+
244
+    **Example Response**:
245
+
246
+    .. sourcecode:: http
247
+
248
+        HTTP/1.1 200
249
+        Vary: Accept
250
+        Content-Type: application/json
251
+
252
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
253
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”},
254
+        {“id”: “ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds”,
255
+        “checksum”: “34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew”}]
256
+
257
+    :statuscode 200: OK
258
+    :statuscode 404: Not found
259
+
260
+Library Repo Images
261
+~~~~~~~~~~~~~~~~~~~
262
+
263
+.. http:put:: /v1/repositories/(repo_name)/images
264
+
265
+    Update the images for a library repo.
266
+
267
+    **Example Request**:
268
+
269
+    .. sourcecode:: http
270
+
271
+        PUT /v1/repositories/foobar/images HTTP/1.1
272
+        Host: index.docker.io
273
+        Accept: application/json
274
+        Content-Type: application/json
275
+        Authorization: Basic akmklmasadalkm==
276
+
277
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
278
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
279
+
280
+    :parameter repo_name: the library name for the repo
281
+
282
+    **Example Response**:
283
+
284
+    .. sourcecode:: http
285
+
286
+        HTTP/1.1 204
287
+        Vary: Accept
288
+        Content-Type: application/json
289
+
290
+        ""
291
+
292
+    :statuscode 204: Created
293
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
294
+    :statuscode 401: Unauthorized
295
+    :statuscode 403: Account is not Active or permission denied
296
+
297
+
298
+.. http:get:: /v1/repositories/(repo_name)/images
299
+
300
+    get the images for a library repo.
301
+
302
+    **Example Request**:
303
+
304
+    .. sourcecode:: http
305
+
306
+        GET /v1/repositories/foobar/images HTTP/1.1
307
+        Host: index.docker.io
308
+        Accept: application/json
309
+
310
+    :parameter repo_name: the library name for the repo
311
+
312
+    **Example Response**:
313
+
314
+    .. sourcecode:: http
315
+
316
+        HTTP/1.1 200
317
+        Vary: Accept
318
+        Content-Type: application/json
319
+
320
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
321
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”},
322
+        {“id”: “ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds”,
323
+        “checksum”: “34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew”}]
324
+
325
+    :statuscode 200: OK
326
+    :statuscode 404: Not found
327
+
328
+
329
+Repository Authorization
330
+************************
331
+
332
+Library Repo
333
+~~~~~~~~~~~~
334
+
335
+.. http:put:: /v1/repositories/(repo_name)/auth
336
+
337
+    authorize a token for a library repo
338
+
339
+    **Example Request**:
340
+
341
+    .. sourcecode:: http
342
+
343
+        PUT /v1/repositories/foobar/auth HTTP/1.1
344
+        Host: index.docker.io
345
+        Accept: application/json
346
+        Authorization: Token signature=123abc,repository="library/foobar",access=write
347
+
348
+    :parameter repo_name: the library name for the repo
349
+
350
+    **Example Response**:
351
+
352
+    .. sourcecode:: http
353
+
354
+        HTTP/1.1 200
355
+        Vary: Accept
356
+        Content-Type: application/json
357
+
358
+        "OK"
359
+
360
+    :statuscode 200: OK
361
+    :statuscode 403: Permission denied
362
+    :statuscode 404: Not found
363
+
364
+
365
+User Repo
366
+~~~~~~~~~
367
+
368
+.. http:put:: /v1/repositories/(namespace)/(repo_name)/auth
369
+
370
+    authorize a token for a user repo
371
+
372
+    **Example Request**:
373
+
374
+    .. sourcecode:: http
375
+
376
+        PUT /v1/repositories/foo/bar/auth HTTP/1.1
377
+        Host: index.docker.io
378
+        Accept: application/json
379
+        Authorization: Token signature=123abc,repository="foo/bar",access=write
380
+
381
+    :parameter namespace: the namespace for the repo
382
+    :parameter repo_name: the name for the repo
383
+
384
+    **Example Response**:
385
+
386
+    .. sourcecode:: http
387
+
388
+        HTTP/1.1 200
389
+        Vary: Accept
390
+        Content-Type: application/json
391
+
392
+        "OK"
393
+
394
+    :statuscode 200: OK
395
+    :statuscode 403: Permission denied
396
+    :statuscode 404: Not found
397
+
398
+
399
+2.2 Users
400
+^^^^^^^^^
401
+
402
+User Login
403
+**********
404
+
405
+.. http:get:: /v1/users
406
+
407
+    If you want to check your login, you can try this endpoint
408
+    
409
+    **Example Request**:
410
+    
411
+    .. sourcecode:: http
412
+    
413
+        GET /v1/users HTTP/1.1
414
+        Host: index.docker.io
415
+        Accept: application/json
416
+        Authorization: Basic akmklmasadalkm==
417
+
418
+    **Example Response**:
419
+
420
+    .. sourcecode:: http
421
+
422
+        HTTP/1.1 200 OK
423
+        Vary: Accept
424
+        Content-Type: application/json
425
+
426
+        OK
427
+
428
+    :statuscode 200: no error
429
+    :statuscode 401: Unauthorized
430
+    :statuscode 403: Account is not Active
431
+
432
+
433
+User Register
434
+*************
435
+
436
+.. http:post:: /v1/users
437
+
438
+    Registering a new account.
439
+
440
+    **Example request**:
441
+
442
+    .. sourcecode:: http
443
+
444
+        POST /v1/users HTTP/1.1
445
+        Host: index.docker.io
446
+        Accept: application/json
447
+        Content-Type: application/json
448
+
449
+        {"email": "sam@dotcloud.com",
450
+         "password": "toto42",
451
+         "username": "foobar"'}
452
+
453
+    :jsonparameter email: valid email address, that needs to be confirmed
454
+    :jsonparameter username: min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
455
+    :jsonparameter password: min 5 characters
456
+
457
+    **Example Response**:
458
+
459
+    .. sourcecode:: http
460
+
461
+        HTTP/1.1 201 OK
462
+        Vary: Accept
463
+        Content-Type: application/json
464
+
465
+        "User Created"
466
+
467
+    :statuscode 201: User Created
468
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
469
+
470
+Update User
471
+***********
472
+
473
+.. http:put:: /v1/users/(username)/
474
+
475
+    Change a password or email address for given user. If you pass in an email,
476
+    it will add it to your account, it will not remove the old one. Passwords will
477
+    be updated.
478
+
479
+    It is up to the client to verify that that password that is sent is the one that
480
+    they want. Common approach is to have them type it twice.
481
+
482
+    **Example Request**:
483
+
484
+    .. sourcecode:: http
485
+
486
+        PUT /v1/users/fakeuser/ HTTP/1.1
487
+        Host: index.docker.io
488
+        Accept: application/json
489
+        Content-Type: application/json
490
+        Authorization: Basic akmklmasadalkm==
491
+
492
+        {"email": "sam@dotcloud.com",
493
+         "password": "toto42"}
494
+
495
+    :parameter username: username for the person you want to update
496
+
497
+    **Example Response**:
498
+
499
+    .. sourcecode:: http
500
+
501
+        HTTP/1.1 204
502
+        Vary: Accept
503
+        Content-Type: application/json
504
+
505
+        ""
506
+
507
+    :statuscode 204: User Updated
508
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
509
+    :statuscode 401: Unauthorized
510
+    :statuscode 403: Account is not Active
511
+    :statuscode 404: User not found
512
+
513
+
514
+2.3 Search
515
+^^^^^^^^^^
516
+If you need to search the index, this is the endpoint you would use.
517
+
518
+Search
519
+******
520
+
521
+.. http:get:: /v1/search
522
+
523
+   Search the Index given a search term. It accepts :http:method:`get` only.
524
+
525
+   **Example request**:
526
+
527
+   .. sourcecode:: http
528
+
529
+      GET /v1/search?q=search_term HTTP/1.1
530
+      Host: example.com
531
+      Accept: application/json
532
+
533
+
534
+   **Example response**:
535
+
536
+   .. sourcecode:: http
537
+
538
+      HTTP/1.1 200 OK
539
+      Vary: Accept
540
+      Content-Type: application/json
541
+
542
+      {"query":"search_term",
543
+        "num_results": 2,
544
+        "results" : [
545
+           {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
546
+           {"name": "base2", "description": "A base ubuntu64  image..."},
547
+         ]
548
+       }
549
+
550
+   :query q: what you want to search for
551
+   :statuscode 200: no error
552
+   :statuscode 500: server error
0 553
deleted file mode 100644
... ...
@@ -1,43 +0,0 @@
1
-:title: Docker Index documentation
2
-:description: Documentation for docker Index
3
-:keywords: docker, index, api
4
-
5
-
6
-=======================
7
-Docker Index Search API
8
-=======================
9
-
10
-Search
11
-
12
-.. http:get:: /v1/search
13
-
14
-   Search the Index given a search term. It accepts :http:method:`get` only.
15
-
16
-   **Example request**:
17
-
18
-   .. sourcecode:: http
19
-
20
-      GET /v1/search?q=search_term HTTP/1.1
21
-      Host: example.com
22
-      Accept: application/json
23
-
24
-   **Example response**:
25
-
26
-   .. sourcecode:: http
27
-
28
-      HTTP/1.1 200 OK
29
-      Vary: Accept
30
-      Content-Type: application/json
31
-
32
-      {"query":"search_term",
33
-        "num_results": 2,
34
-        "results" : [
35
-           {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
36
-           {"name": "base2", "description": "A base ubuntu64  image..."},
37
-         ]
38
-       }
39
-
40
-   :query q: what you want to search for
41
-   :statuscode 200: no error
42
-   :statuscode 500: server error
43 1
\ No newline at end of file
... ...
@@ -1,7 +1,6 @@
1
-:title: Registry Documentation
2
-:description: Documentation for docker Registry and Registry API
3
-:keywords: docker, registry, api, index
4
-
1
+:title: Registry API
2
+:description: API Documentation for Docker Registry
3
+:keywords: API, Docker, index, registry, REST, documentation
5 4
 
6 5
 ===================
7 6
 Docker Registry API
... ...
@@ -9,29 +8,10 @@ Docker Registry API
9 9
 
10 10
 .. contents:: Table of Contents
11 11
 
12
-1. The 3 roles
13
-===============
14
-
15
-1.1 Index
16
-
17
-The Index is responsible for centralizing information about:
18
-- User accounts
19
-- Checksums of the images
20
-- Public namespaces
21
-
22
-The Index has different components:
23
-- Web UI
24
-- Meta-data store (comments, stars, list public repositories)
25
-- Authentication service
26
-- Tokenization
12
+1. Brief introduction
13
+=====================
27 14
 
28
-The index is authoritative for those information.
29
-
30
-We expect that there will be only one instance of the index, run and managed by dotCloud.
31
-
32
-1.2 Registry
15
+- This is the REST API for the Docker Registry
33 16
 - It stores the images and the graph for a set of repositories
34 17
 - It does not have user accounts data
35 18
 - It has no notion of user accounts or authorization
... ...
@@ -60,418 +40,424 @@ We expect that there will be multiple registries out there. To help to grasp the
60 60
 
61 61
 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).
62 62
 
63
-1.3 Docker
64
-
65
-On top of being a runtime for LXC, Docker is the Registry client. It supports:
66
-- Push / Pull on the registry
67
-- Client authentication on the Index
68
-
69
-2. Workflow
70
-===========
71
-
72
-2.1 Pull
73
-
74
-.. image:: /static_files/docker_pull_chart.png
75
-
76
-1. Contact the Index to know where I should download “samalba/busybox”
77
-2. Index replies:
78
-   a. “samalba/busybox” is on Registry A
79
-   b. here are the checksums for “samalba/busybox” (for all layers)
80
-   c. token
81
-3. Contact Registry A to receive the layers for “samalba/busybox” (all of them to the base image). Registry A is authoritative for “samalba/busybox” but keeps a copy of all inherited layers and serve them all from the same location.
82
-4. registry contacts index to verify if token/user is allowed to download images
83
-5. Index returns true/false lettings registry know if it should proceed or error out
84
-6. Get the payload for all layers
85
-
86
-It’s possible to run docker pull \https://<registry>/repositories/samalba/busybox. In this case, docker bypasses the Index. However the security is not guaranteed (in case Registry A is corrupted) because there won’t be any checksum checks.
87
-
88
-Currently registry redirects to s3 urls for downloads, going forward all downloads need to be streamed through the registry. The Registry will then abstract the calls to S3 by a top-level class which implements sub-classes for S3 and local storage.
89
-
90
-Token is only returned when the 'X-Docker-Token' header is sent with request.
91
-
92
-Basic Auth is required to pull private repos. Basic auth isn't required for pulling public repos, but if one is provided, it needs to be valid and for an active account.
93
-
94
-API (pulling repository foo/bar):
95
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96
-
97
-1. (Docker -> Index) GET /v1/repositories/foo/bar/images
98
-    **Headers**:
99
-        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
100
-        X-Docker-Token: true
101
-    **Action**:
102
-        (looking up the foo/bar in db and gets images and checksums for that repo (all if no tag is specified, if tag, only checksums for those tags) see part 4.4.1)
103
-
104
-2. (Index -> Docker) HTTP 200 OK
105
-
106
-    **Headers**:
107
-        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
108
-        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
109
-    **Body**:
110
-        Jsonified checksums (see part 4.4.1)
111
-
112
-3. (Docker -> Registry) GET /v1/repositories/foo/bar/tags/latest
113
-    **Headers**:
114
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
115
-
116
-4. (Registry -> Index) GET /v1/repositories/foo/bar/images
117
-
118
-    **Headers**:
119
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
120
-
121
-    **Body**:
122
-        <ids and checksums in payload>
123
-
124
-    **Action**:
125
-        ( Lookup token see if they have access to pull.)
126
-
127
-        If good:
128
-            HTTP 200 OK
129
-            Index will invalidate the token
130
-        If bad:
131
-            HTTP 401 Unauthorized
132
-
133
-5. (Docker -> Registry) GET /v1/images/928374982374/ancestry
134
-    **Action**:
135
-        (for each image id returned in the registry, fetch /json + /layer)
63
+2. Endpoints
64
+============
136 65
 
137
-.. note::
138
-
139
-    If someone makes a second request, then we will always give a new token, never reuse tokens.
140
-
141
-2.2 Push
142
-
143
-.. image:: /static_files/docker_push_chart.png
144
-
145
-1. Contact the index to allocate the repository name “samalba/busybox” (authentication required with user credentials)
146
-2. If authentication works and namespace available, “samalba/busybox” is allocated and a temporary token is returned (namespace is marked as initialized in index)
147
-3. Push the image on the registry (along with the token)
148
-4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
149
-5. Index validates the token. Registry A starts reading the stream pushed by docker and store the repository (with its images)
150
-6. docker contacts the index to give checksums for upload images
151
-
152
-.. note::
153
-
154
-    **It’s possible not to use the Index at all!** In this case, a deployed version of the Registry is deployed to store and serve images. Those images are not authentified and the security is not guaranteed.
155
-
156
-.. note::
157
-
158
-    **Index can be replaced!** For a private Registry deployed, a custom Index can be used to serve and validate token according to different policies.
159
-
160
-Docker computes the checksums and submit them to the Index at the end of the push. When a repository name does not have checksums on the Index, it means that the push is in progress (since checksums are submitted at the end).
66
+2.1 Images
67
+----------
161 68
 
162
-API (pushing repos foo/bar):
163
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69
+Layer
70
+*****
164 71
 
165
-1. (Docker -> Index) PUT /v1/repositories/foo/bar/
166
-    **Headers**:
167
-        Authorization: Basic sdkjfskdjfhsdkjfh==
168
-        X-Docker-Token: true
72
+.. http:get:: /v1/images/(image_id)/layer 
169 73
 
170
-    **Action**::
171
-        - in index, we allocated a new repository, and set to initialized
74
+    get image layer for a given ``image_id``
172 75
 
173
-    **Body**::
174
-        (The body contains the list of images that are going to be pushed, with empty checksums. The checksums will be set at the end of the push)::
76
+    **Example Request**:
175 77
 
176
-        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
78
+    .. sourcecode:: http
177 79
 
178
-2. (Index -> Docker) 200 Created
179
-    **Headers**:
180
-        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
181
-        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
80
+        GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
81
+        Host: registry-1.docker.io
82
+        Accept: application/json
83
+        Content-Type: application/json
84
+        Authorization: Token akmklmasadalkmsdfgsdgdge33
182 85
 
183
-3. (Docker -> Registry) PUT /v1/images/98765432_parent/json
184
-    **Headers**:
185
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
86
+    :parameter image_id: the id for the layer you want to get
186 87
 
187
-4. (Registry->Index) GET /v1/repositories/foo/bar/images
188
-    **Headers**:
189
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
190
-    **Action**::
191
-        - Index:
192
-            will invalidate the token.
193
-        - Registry:
194
-            grants a session (if token is approved) and fetches the images id
88
+    **Example Response**:
195 89
 
196
-5. (Docker -> Registry) PUT /v1/images/98765432_parent/json
197
-    **Headers**::
198
-        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
199
-        - Cookie: (Cookie provided by the Registry)
90
+    .. sourcecode:: http
200 91
 
201
-6. (Docker -> Registry) PUT /v1/images/98765432/json
202
-    **Headers**:
92
+        HTTP/1.1 200
93
+        Vary: Accept
94
+        Content-Type: application/json
203 95
         Cookie: (Cookie provided by the Registry)
204 96
 
205
-7. (Docker -> Registry) PUT /v1/images/98765432_parent/layer
206
-    **Headers**:
97
+        {
98
+            id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
99
+            parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
100
+            created: "2013-04-30T17:46:10.843673+03:00",
101
+            container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
102
+            container_config: {
103
+                Hostname: "host-test",
104
+                User: "",
105
+                Memory: 0,
106
+                MemorySwap: 0,
107
+                AttachStdin: false,
108
+                AttachStdout: false,
109
+                AttachStderr: false,
110
+                PortSpecs: null,
111
+                Tty: false,
112
+                OpenStdin: false,
113
+                StdinOnce: false,
114
+                Env: null,
115
+                Cmd: [
116
+                "/bin/bash",
117
+                "-c",
118
+                "apt-get -q -yy -f install libevent-dev"
119
+                ],
120
+                Dns: null,
121
+                Image: "imagename/blah",
122
+                Volumes: { },
123
+                VolumesFrom: ""
124
+            },
125
+            docker_version: "0.1.7"
126
+        }
127
+
128
+    :statuscode 200: OK
129
+    :statuscode 401: Requires authorization
130
+    :statuscode 404: Image not found
131
+
132
+
133
+.. http:put:: /v1/images/(image_id)/layer 
134
+
135
+    put image layer for a given ``image_id``
136
+
137
+    **Example Request**:
138
+
139
+    .. sourcecode:: http
140
+
141
+        PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
142
+        Host: registry-1.docker.io
143
+        Accept: application/json
144
+        Content-Type: application/json
145
+        Authorization: Token akmklmasadalkmsdfgsdgdge33
146
+
147
+        {
148
+            id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
149
+            parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
150
+            created: "2013-04-30T17:46:10.843673+03:00",
151
+            container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
152
+            container_config: {
153
+                Hostname: "host-test",
154
+                User: "",
155
+                Memory: 0,
156
+                MemorySwap: 0,
157
+                AttachStdin: false,
158
+                AttachStdout: false,
159
+                AttachStderr: false,
160
+                PortSpecs: null,
161
+                Tty: false,
162
+                OpenStdin: false,
163
+                StdinOnce: false,
164
+                Env: null,
165
+                Cmd: [
166
+                "/bin/bash",
167
+                "-c",
168
+                "apt-get -q -yy -f install libevent-dev"
169
+                ],
170
+                Dns: null,
171
+                Image: "imagename/blah",
172
+                Volumes: { },
173
+                VolumesFrom: ""
174
+            },
175
+            docker_version: "0.1.7"
176
+        }
177
+
178
+    :parameter image_id: the id for the layer you want to get
179
+
180
+
181
+    **Example Response**:
182
+
183
+    .. sourcecode:: http
184
+    
185
+        HTTP/1.1 200
186
+        Vary: Accept
187
+        Content-Type: application/json
188
+
189
+        ""
190
+
191
+    :statuscode 200: OK
192
+    :statuscode 401: Requires authorization
193
+    :statuscode 404: Image not found
194
+
195
+
196
+Image
197
+*****
198
+
199
+.. http:put:: /v1/images/(image_id)/json
200
+
201
+    put image for a given ``image_id``
202
+
203
+    **Example Request**:
204
+
205
+    .. sourcecode:: http
206
+
207
+        PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
208
+        Host: registry-1.docker.io
209
+        Accept: application/json
210
+        Content-Type: application/json
207 211
         Cookie: (Cookie provided by the Registry)
208 212
 
209
-8. (Docker -> Registry) PUT /v1/images/98765432/layer
210
-    **Headers**:
211
-        X-Docker-Checksum: sha256:436745873465fdjkhdfjkgh
213
+        {
214
+         “id”: “088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c”,
215
+         “checksum”:  “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
216
+         }
212 217
 
213
-9. (Docker -> Registry) PUT /v1/repositories/foo/bar/tags/latest
214
-    **Headers**:
215
-        Cookie: (Cookie provided by the Registry)
216
-    **Body**:
217
-        “98765432”
218
+    :parameter image_id: the id for the layer you want to get
218 219
 
219
-10. (Docker -> Index) PUT /v1/repositories/foo/bar/images
220 220
 
221
-    **Headers**:
222
-        Authorization: Basic 123oislifjsldfj==
223
-        X-Docker-Endpoints: registry1.docker.io (no validation on this right now)
221
+    **Example Response**:
224 222
 
225
-    **Body**:
226
-        (The image, id’s, tags and checksums)
223
+    .. sourcecode:: http
224
+    
225
+        HTTP/1.1 200
226
+        Vary: Accept
227
+        Content-Type: application/json
227 228
 
228
-        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
229
-        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
229
+        ""
230 230
 
231
-    **Return** HTTP 204
231
+    :statuscode 200: OK
232
+    :statuscode 401: Requires authorization
232 233
 
233
-.. note::
234
+.. http:get:: /v1/images/(image_id)/json
234 235
 
235
-     If push fails and they need to start again, what happens in the index, there will already be a record for the namespace/name, but it will be initialized. Should we allow it, or mark as name already used? One edge case could be if someone pushes the same thing at the same time with two different shells.
236
+    get image for a given ``image_id``
236 237
 
237
-     If it's a retry on the Registry, Docker has a cookie (provided by the registry after token validation). So the Index won’t have to provide a new token.
238
+    **Example Request**:
238 239
 
239
-3. How to use the Registry in standalone mode
240
-=============================================
240
+    .. sourcecode:: http
241 241
 
242
-The Index has two main purposes (along with its fancy social features):
242
+        GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
243
+        Host: registry-1.docker.io
244
+        Accept: application/json
245
+        Content-Type: application/json
246
+        Cookie: (Cookie provided by the Registry)
243 247
 
244
-- Resolve short names (to avoid passing absolute URLs all the time)
245
-   - username/projectname -> \https://registry.docker.io/users/<username>/repositories/<projectname>/
246
-- Authenticate a user as a repos owner (for a central referenced repository)
248
+    :parameter image_id: the id for the layer you want to get
247 249
 
248
-3.1 Without an Index
249
-Using the Registry without the Index can be useful to store the images on a private network without having to rely on an external entity controlled by dotCloud.
250
+    **Example Response**:
250 251
 
251
-In this case, the registry will be launched in a special mode (--standalone? --no-index?). In this mode, the only thing which changes is that Registry will never contact the Index to verify a token. It will be the Registry owner responsibility to authenticate the user who pushes (or even pulls) an image using any mechanism (HTTP auth, IP based, etc...).
252
+    .. sourcecode:: http
252 253
 
253
-In this scenario, the Registry is responsible for the security in case of data corruption since the checksums are not delivered by a trusted entity.
254
+        HTTP/1.1 200
255
+        Vary: Accept
256
+        Content-Type: application/json
254 257
 
255
-As hinted previously, a standalone registry can also be implemented by any HTTP server handling GET/PUT requests (or even only GET requests if no write access is necessary).
258
+        {
259
+         “id”: “088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c”,
260
+         “checksum”:  “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
261
+         }
256 262
 
257
-3.2 With an Index
263
+    :statuscode 200: OK
264
+    :statuscode 401: Requires authorization
265
+    :statuscode 404: Image not found
258 266
 
259
-The Index data needed by the Registry are simple:
260
-- Serve the checksums
261
-- Provide and authorize a Token
262 267
 
263
-In the scenario of a Registry running on a private network with the need of centralizing and authorizing, it’s easy to use a custom Index.
268
+Ancestry
269
+********
264 270
 
265
-The only challenge will be to tell Docker to contact (and trust) this custom Index. Docker will be configurable at some point to use a specific Index, it’ll be the private entity responsibility (basically the organization who uses Docker in a private environment) to maintain the Index and the Docker’s configuration among its consumers.
271
+.. http:get:: /v1/images/(image_id)/ancestry
266 272
 
267
-4. The API
268
-==========
273
+    get ancestry for an image given an ``image_id``
269 274
 
270
-The first version of the api is available here: https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull.md
275
+    **Example Request**:
271 276
 
272
-4.1 Images
277
+    .. sourcecode:: http
273 278
 
274
-The format returned in the images is not defined here (for layer and json), basically because Registry stores exactly the same kind of information as Docker uses to manage them.
275
-
276
-The format of ancestry is a line-separated list of image ids, in age order. I.e. the image’s parent is on the last line, the parent of the parent on the next-to-last line, etc.; if the image has no parent, the file is empty.
279
+        GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/ancestry 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)
277 284
 
278
-GET /v1/images/<image_id>/layer
279
-PUT /v1/images/<image_id>/layer
280
-GET /v1/images/<image_id>/json
281
-PUT /v1/images/<image_id>/json
282
-GET /v1/images/<image_id>/ancestry
283
-PUT /v1/images/<image_id>/ancestry
285
+    :parameter image_id: the id for the layer you want to get
284 286
 
285
-4.2 Users
287
+    **Example Response**:
286 288
 
287
-4.2.1 Create a user (Index)
288
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
289
+    .. sourcecode:: http
289 290
 
290
-POST /v1/users
291
+        HTTP/1.1 200
292
+        Vary: Accept
293
+        Content-Type: application/json
291 294
 
292
-**Body**:
293
-    {"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
295
+        ["088b4502f51920fbd9b7c503e87c7a2c05aa3adc3d35e79c031fa126b403200f",
296
+         "aeee63968d87c7da4a5cf5d2be6bee4e21bc226fd62273d180a49c96c62e4543",
297
+         "bfa4c5326bc764280b0863b46a4b20d940bc1897ef9c1dfec060604bdc383280",
298
+         "6ab5893c6927c15a15665191f2c6cf751f5056d8b95ceee32e43c5e8a3648544"]
294 299
 
295
-**Validation**:
296
-    - **username** : min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
297
-    - **password**: min 5 characters
300
+    :statuscode 200: OK
301
+    :statuscode 401: Requires authorization
302
+    :statuscode 404: Image not found
298 303
 
299
-**Valid**: return HTTP 200
300 304
 
301
-Errors: HTTP 400 (we should create error codes for possible errors)
302
-- invalid json
303
-- missing field
304
-- wrong format (username, password, email, etc)
305
-- forbidden name
306
-- name already exists
305
+2.2 Tags
306
+--------
307 307
 
308
-.. note::
308
+.. http:get:: /v1/repositories/(namespace)/(repository)/tags
309 309
 
310
-    A user account will be valid only if the email has been validated (a validation link is sent to the email address).
310
+    get all of the tags for the given repo.
311 311
 
312
-4.2.2 Update a user (Index)
313
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
312
+    **Example Request**:
314 313
 
315
-PUT /v1/users/<username>
314
+    .. sourcecode:: http
316 315
 
317
-**Body**:
318
-    {"password": "toto"}
316
+        GET /v1/repositories/foo/bar/tags HTTP/1.1
317
+        Host: registry-1.docker.io
318
+        Accept: application/json
319
+        Content-Type: application/json
320
+        Cookie: (Cookie provided by the Registry)
319 321
 
320
-.. note::
322
+    :parameter namespace: namespace for the repo
323
+    :parameter repository: name for the repo
321 324
 
322
-    We can also update email address, if they do, they will need to reverify their new email address.
325
+    **Example Response**:
323 326
 
324
-4.2.3 Login (Index)
325
-^^^^^^^^^^^^^^^^^^^
326
-Does nothing else but asking for a user authentication. Can be used to validate credentials. HTTP Basic Auth for now, maybe change in future.
327
+    .. sourcecode:: http
327 328
 
328
-GET /v1/users
329
+        HTTP/1.1 200
330
+        Vary: Accept
331
+        Content-Type: application/json
329 332
 
330
-**Return**:
331
-    - Valid: HTTP 200
332
-    - Invalid login: HTTP 401
333
-    - Account inactive: HTTP 403 Account is not Active
333
+        {
334
+            "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
335
+            “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
336
+        }
334 337
 
335
-4.3 Tags (Registry)
338
+    :statuscode 200: OK
339
+    :statuscode 401: Requires authorization
340
+    :statuscode 404: Repository not found
336 341
 
337
-The Registry does not know anything about users. Even though repositories are under usernames, it’s just a namespace for the registry. Allowing us to implement organizations or different namespaces per user later, without modifying the Registry’s API.
338 342
 
339
-The following naming restrictions apply:
343
+.. http:get:: /v1/repositories/(namespace)/(repository)/tags/(tag)
340 344
 
341
-- Namespaces must match the same regular expression as usernames (See 4.2.1.)
342
-- Repository names must match the regular expression [a-zA-Z0-9-_.]
345
+    get a tag for the given repo.
343 346
 
344
-4.3.1 Get all tags
345
-^^^^^^^^^^^^^^^^^^
347
+    **Example Request**:
346 348
 
347
-GET /v1/repositories/<namespace>/<repository_name>/tags
349
+    .. sourcecode:: http
348 350
 
349
-**Return**: HTTP 200
350
-    {
351
-    "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
352
-    “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
353
-    }
351
+        GET /v1/repositories/foo/bar/tags/latest HTTP/1.1
352
+        Host: registry-1.docker.io
353
+        Accept: application/json
354
+        Content-Type: application/json
355
+        Cookie: (Cookie provided by the Registry)
354 356
 
355
-4.3.2 Read the content of a tag (resolve the image id)
356
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
357
+    :parameter namespace: namespace for the repo
358
+    :parameter repository: name for the repo
359
+    :parameter tag: name of tag you want to get
357 360
 
358
-GET /v1/repositories/<namespace>/<repo_name>/tags/<tag>
361
+    **Example Response**:
359 362
 
360
-**Return**:
361
-    "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
363
+    .. sourcecode:: http
362 364
 
363
-4.3.3 Delete a tag (registry)
364
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
365
+        HTTP/1.1 200
366
+        Vary: Accept
367
+        Content-Type: application/json
365 368
 
366
-DELETE /v1/repositories/<namespace>/<repo_name>/tags/<tag>
369
+        "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
367 370
 
368
-4.4 Images (Index)
371
+    :statuscode 200: OK
372
+    :statuscode 401: Requires authorization
373
+    :statuscode 404: Tag not found
369 374
 
370
-For the Index to “resolve” the repository name to a Registry location, it uses the X-Docker-Endpoints header. In other terms, this requests always add a “X-Docker-Endpoints” to indicate the location of the registry which hosts this repository.
375
+.. http:delete:: /v1/repositories/(namespace)/(repository)/tags/(tag)
371 376
 
372
-4.4.1 Get the images
373
-^^^^^^^^^^^^^^^^^^^^^
377
+    delete the tag for the repo
374 378
 
375
-GET /v1/repositories/<namespace>/<repo_name>/images
379
+    **Example Request**:
376 380
 
377
-**Return**: HTTP 200
378
-    [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
381
+    .. sourcecode:: http
379 382
 
383
+        DELETE /v1/repositories/foo/bar/tags/latest HTTP/1.1
384
+        Host: registry-1.docker.io
385
+        Accept: application/json
386
+        Content-Type: application/json
387
+        Cookie: (Cookie provided by the Registry)
380 388
 
381
-4.4.2 Add/update the images
382
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
389
+    :parameter namespace: namespace for the repo
390
+    :parameter repository: name for the repo
391
+    :parameter tag: name of tag you want to delete
383 392
 
384
-You always add images, you never remove them.
393
+    **Example Response**:
385 394
 
386
-PUT /v1/repositories/<namespace>/<repo_name>/images
395
+    .. sourcecode:: http
387 396
 
388
-**Body**:
389
-    [ {“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”} ]
397
+        HTTP/1.1 200
398
+        Vary: Accept
399
+        Content-Type: application/json
390 400
 
391
-**Return** 204
401
+        ""
392 402
 
393
-5. Chaining Registries
394
-======================
403
+    :statuscode 200: OK
404
+    :statuscode 401: Requires authorization
405
+    :statuscode 404: Tag not found
395 406
 
396
-It’s possible to chain Registries server for several reasons:
397
-- Load balancing
398
-- Delegate the next request to another server
399 407
 
400
-When a Registry is a reference for a repository, it should host the entire images chain in order to avoid breaking the chain during the download.
408
+.. http:put:: /v1/repositories/(namespace)/(repository)/tags/(tag)
401 409
 
402
-The Index and Registry use this mechanism to redirect on one or the other.
410
+    put a tag for the given repo.
403 411
 
404
-Example with an image download:
405
-On every request, a special header can be returned:
412
+    **Example Request**:
406 413
 
407
-X-Docker-Endpoints: server1,server2
414
+    .. sourcecode:: http
408 415
 
409
-On the next request, the client will always pick a server from this list.
416
+        PUT /v1/repositories/foo/bar/tags/latest HTTP/1.1
417
+        Host: registry-1.docker.io
418
+        Accept: application/json
419
+        Content-Type: application/json
420
+        Cookie: (Cookie provided by the Registry)
410 421
 
411
-6. Authentication & Authorization
412
-=================================
422
+        “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”
413 423
 
414
-6.1 On the Index
424
+    :parameter namespace: namespace for the repo
425
+    :parameter repository: name for the repo
426
+    :parameter tag: name of tag you want to add
415 427
 
416
-The Index supports both “Basic” and “Token” challenges. Usually when there is a “401 Unauthorized”, the Index replies this::
428
+    **Example Response**:
417 429
 
418
-    401 Unauthorized
419
-    WWW-Authenticate: Basic realm="auth required",Token
430
+    .. sourcecode:: http
420 431
 
421
-You have 3 options:
432
+        HTTP/1.1 200
433
+        Vary: Accept
434
+        Content-Type: application/json
422 435
 
423
-1. Provide user credentials and ask for a token
436
+        ""
424 437
 
425
-    **Header**:
426
-        - Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
427
-        - X-Docker-Token: true
438
+    :statuscode 200: OK
439
+    :statuscode 400: Invalid data
440
+    :statuscode 401: Requires authorization
441
+    :statuscode 404: Image not found
428 442
 
429
-    In this case, along with the 200 response, you’ll get a new token (if user auth is ok):
430
-    If authorization isn't correct you get a 401 response.
431
-    If account isn't active you will get a 403 response.
443
+2.3 Repositories
444
+----------------
432 445
 
433
-    **Response**:
434
-        - 200 OK
435
-        - X-Docker-Token: Token signature=123abc,repository=”foo/bar”,access=read
446
+.. http:delete:: /v1/repositories/(namespace)/(repository)/
436 447
 
437
-2. Provide user credentials only
448
+    delete a repository
438 449
 
439
-    **Header**:
440
-        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
450
+    **Example Request**:
441 451
 
442
-3. Provide Token
452
+    .. sourcecode:: http
443 453
 
444
-    **Header**:
445
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
454
+        DELETE /v1/repositories/foo/bar/ HTTP/1.1
455
+        Host: registry-1.docker.io
456
+        Accept: application/json
457
+        Content-Type: application/json
458
+        Cookie: (Cookie provided by the Registry)
446 459
 
447
-6.2 On the Registry
460
+        ""
448 461
 
449
-The Registry only supports the Token challenge::
462
+    :parameter namespace: namespace for the repo
463
+    :parameter repository: name for the repo
450 464
 
451
-    401 Unauthorized
452
-    WWW-Authenticate: Token
465
+    **Example Response**:
453 466
 
454
-The only way is to provide a token on “401 Unauthorized” responses::
467
+    .. sourcecode:: http
455 468
 
456
-    Authorization: Token signature=123abc,repository=”foo/bar”,access=read
469
+        HTTP/1.1 200
470
+        Vary: Accept
471
+        Content-Type: application/json
457 472
 
458
-Usually, the Registry provides a Cookie when a Token verification succeeded. Every time the Registry passes a Cookie, you have to pass it back the same cookie.::
473
+        ""
459 474
 
460
-    200 OK
461
-    Set-Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="; Path=/; HttpOnly
475
+    :statuscode 200: OK
476
+    :statuscode 401: Requires authorization
477
+    :statuscode 404: Repository not found
462 478
 
463
-Next request::
479
+3.0 Authorization
480
+=================
481
+This is where we describe the authorization process, including the tokens and cookies. 
464 482
 
465
-    GET /(...)
466
-    Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="
483
+TODO: add more info.
467 484
new file mode 100644
... ...
@@ -0,0 +1,569 @@
0
+:title: Registry Documentation
1
+:description: Documentation for docker Registry and Registry API
2
+:keywords: docker, registry, api, index
3
+
4
+
5
+=====================
6
+Registry & index Spec
7
+=====================
8
+
9
+.. contents:: Table of Contents
10
+
11
+1. The 3 roles
12
+===============
13
+
14
+1.1 Index
15
+---------
16
+
17
+The Index is responsible for centralizing information about:
18
+- User accounts
19
+- Checksums of the images
20
+- Public namespaces
21
+
22
+The Index has different components:
23
+- Web UI
24
+- Meta-data store (comments, stars, list public repositories)
25
+- Authentication service
26
+- Tokenization
27
+
28
+The index is authoritative for those information.
29
+
30
+We expect that there will be only one instance of the index, run and managed by dotCloud.
31
+
32
+1.2 Registry
33
+------------
34
+- It stores the images and the graph for a set of repositories
35
+- It does not have user accounts data
36
+- It has no notion of user accounts or authorization
37
+- It delegates authentication and authorization to the Index Auth service using tokens
38
+- It supports different storage backends (S3, cloud files, local FS)
39
+- It doesn’t have a local database
40
+- It will be open-sourced at some point
41
+
42
+We expect that there will be multiple registries out there. To help to grasp the context, here are some examples of registries:
43
+
44
+- **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.
45
+- **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.
46
+- **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.
47
+- **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.
48
+
49
+.. note::
50
+
51
+    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.
52
+
53
+.. note::
54
+
55
+    The latter implies that while HTTP is the protocol of choice for a registry, multiple schemes are possible (and in some cases, trivial):
56
+        - HTTP with GET (and PUT for read-write registries);
57
+        - local mount point;
58
+        - remote docker addressed through SSH.
59
+
60
+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).
61
+
62
+1.3 Docker
63
+----------
64
+
65
+On top of being a runtime for LXC, Docker is the Registry client. It supports:
66
+- Push / Pull on the registry
67
+- Client authentication on the Index
68
+
69
+2. Workflow
70
+===========
71
+
72
+2.1 Pull
73
+--------
74
+
75
+.. image:: /static_files/docker_pull_chart.png
76
+
77
+1. Contact the Index to know where I should download “samalba/busybox”
78
+2. Index replies:
79
+   a. “samalba/busybox” is on Registry A
80
+   b. here are the checksums for “samalba/busybox” (for all layers)
81
+   c. token
82
+3. Contact Registry A to receive the layers for “samalba/busybox” (all of them to the base image). Registry A is authoritative for “samalba/busybox” but keeps a copy of all inherited layers and serve them all from the same location.
83
+4. registry contacts index to verify if token/user is allowed to download images
84
+5. Index returns true/false lettings registry know if it should proceed or error out
85
+6. Get the payload for all layers
86
+
87
+It’s possible to run docker pull \https://<registry>/repositories/samalba/busybox. In this case, docker bypasses the Index. However the security is not guaranteed (in case Registry A is corrupted) because there won’t be any checksum checks.
88
+
89
+Currently registry redirects to s3 urls for downloads, going forward all downloads need to be streamed through the registry. The Registry will then abstract the calls to S3 by a top-level class which implements sub-classes for S3 and local storage.
90
+
91
+Token is only returned when the 'X-Docker-Token' header is sent with request.
92
+
93
+Basic Auth is required to pull private repos. Basic auth isn't required for pulling public repos, but if one is provided, it needs to be valid and for an active account.
94
+
95
+API (pulling repository foo/bar):
96
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
+
98
+1. (Docker -> Index) GET /v1/repositories/foo/bar/images
99
+    **Headers**:
100
+        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
101
+        X-Docker-Token: true
102
+    **Action**:
103
+        (looking up the foo/bar in db and gets images and checksums for that repo (all if no tag is specified, if tag, only checksums for those tags) see part 4.4.1)
104
+
105
+2. (Index -> Docker) HTTP 200 OK
106
+
107
+    **Headers**:
108
+        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
109
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
110
+    **Body**:
111
+        Jsonified checksums (see part 4.4.1)
112
+
113
+3. (Docker -> Registry) GET /v1/repositories/foo/bar/tags/latest
114
+    **Headers**:
115
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
116
+
117
+4. (Registry -> Index) GET /v1/repositories/foo/bar/images
118
+
119
+    **Headers**:
120
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
121
+
122
+    **Body**:
123
+        <ids and checksums in payload>
124
+
125
+    **Action**:
126
+        ( Lookup token see if they have access to pull.)
127
+
128
+        If good:
129
+            HTTP 200 OK
130
+            Index will invalidate the token
131
+        If bad:
132
+            HTTP 401 Unauthorized
133
+
134
+5. (Docker -> Registry) GET /v1/images/928374982374/ancestry
135
+    **Action**:
136
+        (for each image id returned in the registry, fetch /json + /layer)
137
+
138
+.. note::
139
+
140
+    If someone makes a second request, then we will always give a new token, never reuse tokens.
141
+
142
+2.2 Push
143
+--------
144
+
145
+.. image:: /static_files/docker_push_chart.png
146
+
147
+1. Contact the index to allocate the repository name “samalba/busybox” (authentication required with user credentials)
148
+2. If authentication works and namespace available, “samalba/busybox” is allocated and a temporary token is returned (namespace is marked as initialized in index)
149
+3. Push the image on the registry (along with the token)
150
+4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
151
+5. Index validates the token. Registry A starts reading the stream pushed by docker and store the repository (with its images)
152
+6. docker contacts the index to give checksums for upload images
153
+
154
+.. note::
155
+
156
+    **It’s possible not to use the Index at all!** In this case, a deployed version of the Registry is deployed to store and serve images. Those images are not authentified and the security is not guaranteed.
157
+
158
+.. note::
159
+
160
+    **Index can be replaced!** For a private Registry deployed, a custom Index can be used to serve and validate token according to different policies.
161
+
162
+Docker computes the checksums and submit them to the Index at the end of the push. When a repository name does not have checksums on the Index, it means that the push is in progress (since checksums are submitted at the end).
163
+
164
+API (pushing repos foo/bar):
165
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166
+
167
+1. (Docker -> Index) PUT /v1/repositories/foo/bar/
168
+    **Headers**:
169
+        Authorization: Basic sdkjfskdjfhsdkjfh==
170
+        X-Docker-Token: true
171
+
172
+    **Action**::
173
+        - in index, we allocated a new repository, and set to initialized
174
+
175
+    **Body**::
176
+        (The body contains the list of images that are going to be pushed, with empty checksums. The checksums will be set at the end of the push)::
177
+
178
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
179
+
180
+2. (Index -> Docker) 200 Created
181
+    **Headers**:
182
+        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
183
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
184
+
185
+3. (Docker -> Registry) PUT /v1/images/98765432_parent/json
186
+    **Headers**:
187
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
188
+
189
+4. (Registry->Index) GET /v1/repositories/foo/bar/images
190
+    **Headers**:
191
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
192
+    **Action**::
193
+        - Index:
194
+            will invalidate the token.
195
+        - Registry:
196
+            grants a session (if token is approved) and fetches the images id
197
+
198
+5. (Docker -> Registry) PUT /v1/images/98765432_parent/json
199
+    **Headers**::
200
+        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
201
+        - Cookie: (Cookie provided by the Registry)
202
+
203
+6. (Docker -> Registry) PUT /v1/images/98765432/json
204
+    **Headers**:
205
+        Cookie: (Cookie provided by the Registry)
206
+
207
+7. (Docker -> Registry) PUT /v1/images/98765432_parent/layer
208
+    **Headers**:
209
+        Cookie: (Cookie provided by the Registry)
210
+
211
+8. (Docker -> Registry) PUT /v1/images/98765432/layer
212
+    **Headers**:
213
+        X-Docker-Checksum: sha256:436745873465fdjkhdfjkgh
214
+
215
+9. (Docker -> Registry) PUT /v1/repositories/foo/bar/tags/latest
216
+    **Headers**:
217
+        Cookie: (Cookie provided by the Registry)
218
+    **Body**:
219
+        “98765432”
220
+
221
+10. (Docker -> Index) PUT /v1/repositories/foo/bar/images
222
+
223
+    **Headers**:
224
+        Authorization: Basic 123oislifjsldfj==
225
+        X-Docker-Endpoints: registry1.docker.io (no validation on this right now)
226
+
227
+    **Body**:
228
+        (The image, id’s, tags and checksums)
229
+
230
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
231
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
232
+
233
+    **Return** HTTP 204
234
+
235
+.. note::
236
+
237
+     If push fails and they need to start again, what happens in the index, there will already be a record for the namespace/name, but it will be initialized. Should we allow it, or mark as name already used? One edge case could be if someone pushes the same thing at the same time with two different shells.
238
+
239
+     If it's a retry on the Registry, Docker has a cookie (provided by the registry after token validation). So the Index won’t have to provide a new token.
240
+
241
+2.3 Delete
242
+----------
243
+
244
+If you need to delete something from the index or registry, we need a nice clean way to do that. Here is the workflow.
245
+
246
+1. Docker contacts the index to request a delete of a repository “samalba/busybox” (authentication required with user credentials)
247
+2. If authentication works and repository is valid, “samalba/busybox” is marked as deleted and a temporary token is returned
248
+3. Send a delete request to the registry for the repository (along with the token)
249
+4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
250
+5. Index validates the token. Registry A deletes the repository and everything associated to it.
251
+6. docker contacts the index to let it know it was removed from the registry, the index removes all records from the database.
252
+
253
+.. note::
254
+
255
+    The Docker client should present an "Are you sure?" prompt to confirm the deletion before starting the process. Once it starts it can't be undone.
256
+
257
+API (deleting repository foo/bar):
258
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
259
+
260
+1. (Docker -> Index) DELETE /v1/repositories/foo/bar/
261
+    **Headers**:
262
+        Authorization: Basic sdkjfskdjfhsdkjfh==
263
+        X-Docker-Token: true
264
+
265
+    **Action**::
266
+        - in index, we make sure it is a valid repository, and set to deleted (logically)
267
+
268
+    **Body**::
269
+        Empty
270
+
271
+2. (Index -> Docker) 202 Accepted
272
+    **Headers**:
273
+        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=delete
274
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]   # list of endpoints where this repo lives.
275
+
276
+3. (Docker -> Registry) DELETE /v1/repositories/foo/bar/
277
+    **Headers**:
278
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=delete
279
+
280
+4. (Registry->Index) PUT /v1/repositories/foo/bar/auth
281
+    **Headers**:
282
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=delete
283
+    **Action**::
284
+        - Index:
285
+            will invalidate the token.
286
+        - Registry:
287
+            deletes the repository (if token is approved)
288
+
289
+5. (Registry -> Docker) 200 OK
290
+        200 If success 
291
+        403 if forbidden
292
+        400 if bad request
293
+        404 if repository isn't found
294
+
295
+6. (Docker -> Index) DELETE /v1/repositories/foo/bar/
296
+
297
+    **Headers**:
298
+        Authorization: Basic 123oislifjsldfj==
299
+        X-Docker-Endpoints: registry-1.docker.io (no validation on this right now)
300
+
301
+    **Body**:
302
+        Empty
303
+
304
+    **Return** HTTP 200
305
+
306
+
307
+3. How to use the Registry in standalone mode
308
+=============================================
309
+
310
+The Index has two main purposes (along with its fancy social features):
311
+
312
+- Resolve short names (to avoid passing absolute URLs all the time)
313
+   - username/projectname -> \https://registry.docker.io/users/<username>/repositories/<projectname>/
314
+   - team/projectname -> \https://registry.docker.io/team/<team>/repositories/<projectname>/
315
+- Authenticate a user as a repos owner (for a central referenced repository)
316
+
317
+3.1 Without an Index
318
+--------------------
319
+Using the Registry without the Index can be useful to store the images on a private network without having to rely on an external entity controlled by dotCloud.
320
+
321
+In this case, the registry will be launched in a special mode (--standalone? --no-index?). In this mode, the only thing which changes is that Registry will never contact the Index to verify a token. It will be the Registry owner responsibility to authenticate the user who pushes (or even pulls) an image using any mechanism (HTTP auth, IP based, etc...).
322
+
323
+In this scenario, the Registry is responsible for the security in case of data corruption since the checksums are not delivered by a trusted entity.
324
+
325
+As hinted previously, a standalone registry can also be implemented by any HTTP server handling GET/PUT requests (or even only GET requests if no write access is necessary).
326
+
327
+3.2 With an Index
328
+-----------------
329
+
330
+The Index data needed by the Registry are simple:
331
+- Serve the checksums
332
+- Provide and authorize a Token
333
+
334
+In the scenario of a Registry running on a private network with the need of centralizing and authorizing, it’s easy to use a custom Index.
335
+
336
+The only challenge will be to tell Docker to contact (and trust) this custom Index. Docker will be configurable at some point to use a specific Index, it’ll be the private entity responsibility (basically the organization who uses Docker in a private environment) to maintain the Index and the Docker’s configuration among its consumers.
337
+
338
+4. The API
339
+==========
340
+
341
+The first version of the api is available here: https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull.md
342
+
343
+4.1 Images
344
+----------
345
+
346
+The format returned in the images is not defined here (for layer and json), basically because Registry stores exactly the same kind of information as Docker uses to manage them.
347
+
348
+The format of ancestry is a line-separated list of image ids, in age order. I.e. the image’s parent is on the last line, the parent of the parent on the next-to-last line, etc.; if the image has no parent, the file is empty.
349
+
350
+GET /v1/images/<image_id>/layer
351
+PUT /v1/images/<image_id>/layer
352
+GET /v1/images/<image_id>/json
353
+PUT /v1/images/<image_id>/json
354
+GET /v1/images/<image_id>/ancestry
355
+PUT /v1/images/<image_id>/ancestry
356
+
357
+4.2 Users
358
+---------
359
+
360
+4.2.1 Create a user (Index)
361
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
362
+
363
+POST /v1/users
364
+
365
+**Body**:
366
+    {"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
367
+
368
+**Validation**:
369
+    - **username** : min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
370
+    - **password**: min 5 characters
371
+
372
+**Valid**: return HTTP 200
373
+
374
+Errors: HTTP 400 (we should create error codes for possible errors)
375
+- invalid json
376
+- missing field
377
+- wrong format (username, password, email, etc)
378
+- forbidden name
379
+- name already exists
380
+
381
+.. note::
382
+
383
+    A user account will be valid only if the email has been validated (a validation link is sent to the email address).
384
+
385
+4.2.2 Update a user (Index)
386
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
387
+
388
+PUT /v1/users/<username>
389
+
390
+**Body**:
391
+    {"password": "toto"}
392
+
393
+.. note::
394
+
395
+    We can also update email address, if they do, they will need to reverify their new email address.
396
+
397
+4.2.3 Login (Index)
398
+^^^^^^^^^^^^^^^^^^^
399
+Does nothing else but asking for a user authentication. Can be used to validate credentials. HTTP Basic Auth for now, maybe change in future.
400
+
401
+GET /v1/users
402
+
403
+**Return**:
404
+    - Valid: HTTP 200
405
+    - Invalid login: HTTP 401
406
+    - Account inactive: HTTP 403 Account is not Active
407
+
408
+4.3 Tags (Registry)
409
+-------------------
410
+
411
+The Registry does not know anything about users. Even though repositories are under usernames, it’s just a namespace for the registry. Allowing us to implement organizations or different namespaces per user later, without modifying the Registry’s API.
412
+
413
+The following naming restrictions apply:
414
+
415
+- Namespaces must match the same regular expression as usernames (See 4.2.1.)
416
+- Repository names must match the regular expression [a-zA-Z0-9-_.]
417
+
418
+4.3.1 Get all tags
419
+^^^^^^^^^^^^^^^^^^
420
+
421
+GET /v1/repositories/<namespace>/<repository_name>/tags
422
+
423
+**Return**: HTTP 200
424
+    {
425
+    "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
426
+    “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
427
+    }
428
+
429
+4.3.2 Read the content of a tag (resolve the image id)
430
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
431
+
432
+GET /v1/repositories/<namespace>/<repo_name>/tags/<tag>
433
+
434
+**Return**:
435
+    "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
436
+
437
+4.3.3 Delete a tag (registry)
438
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439
+
440
+DELETE /v1/repositories/<namespace>/<repo_name>/tags/<tag>
441
+
442
+4.4 Images (Index)
443
+------------------
444
+
445
+For the Index to “resolve” the repository name to a Registry location, it uses the X-Docker-Endpoints header. In other terms, this requests always add a “X-Docker-Endpoints” to indicate the location of the registry which hosts this repository.
446
+
447
+4.4.1 Get the images
448
+^^^^^^^^^^^^^^^^^^^^^
449
+
450
+GET /v1/repositories/<namespace>/<repo_name>/images
451
+
452
+**Return**: HTTP 200
453
+    [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
454
+
455
+
456
+4.4.2 Add/update the images
457
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
458
+
459
+You always add images, you never remove them.
460
+
461
+PUT /v1/repositories/<namespace>/<repo_name>/images
462
+
463
+**Body**:
464
+    [ {“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”} ]
465
+
466
+**Return** 204
467
+
468
+4.5 Repositories
469
+----------------
470
+
471
+4.5.1 Remove a Repository (Registry)
472
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
473
+
474
+DELETE /v1/repositories/<namespace>/<repo_name>
475
+
476
+Return 200 OK
477
+
478
+4.5.2 Remove a Repository (Index)
479
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
480
+This starts the delete process. see 2.3 for more details.
481
+
482
+DELETE /v1/repositories/<namespace>/<repo_name>
483
+
484
+Return 202 OK
485
+
486
+5. Chaining Registries
487
+======================
488
+
489
+It’s possible to chain Registries server for several reasons:
490
+- Load balancing
491
+- Delegate the next request to another server
492
+
493
+When a Registry is a reference for a repository, it should host the entire images chain in order to avoid breaking the chain during the download.
494
+
495
+The Index and Registry use this mechanism to redirect on one or the other.
496
+
497
+Example with an image download:
498
+On every request, a special header can be returned:
499
+
500
+X-Docker-Endpoints: server1,server2
501
+
502
+On the next request, the client will always pick a server from this list.
503
+
504
+6. Authentication & Authorization
505
+=================================
506
+
507
+6.1 On the Index
508
+-----------------
509
+
510
+The Index supports both “Basic” and “Token” challenges. Usually when there is a “401 Unauthorized”, the Index replies this::
511
+
512
+    401 Unauthorized
513
+    WWW-Authenticate: Basic realm="auth required",Token
514
+
515
+You have 3 options:
516
+
517
+1. Provide user credentials and ask for a token
518
+
519
+    **Header**:
520
+        - Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
521
+        - X-Docker-Token: true
522
+
523
+    In this case, along with the 200 response, you’ll get a new token (if user auth is ok):
524
+    If authorization isn't correct you get a 401 response.
525
+    If account isn't active you will get a 403 response.
526
+
527
+    **Response**:
528
+        - 200 OK
529
+        - X-Docker-Token: Token signature=123abc,repository=”foo/bar”,access=read
530
+
531
+2. Provide user credentials only
532
+
533
+    **Header**:
534
+        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
535
+
536
+3. Provide Token
537
+
538
+    **Header**:
539
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
540
+
541
+6.2 On the Registry
542
+-------------------
543
+
544
+The Registry only supports the Token challenge::
545
+
546
+    401 Unauthorized
547
+    WWW-Authenticate: Token
548
+
549
+The only way is to provide a token on “401 Unauthorized” responses::
550
+
551
+    Authorization: Token signature=123abc,repository=”foo/bar”,access=read
552
+
553
+Usually, the Registry provides a Cookie when a Token verification succeeded. Every time the Registry passes a Cookie, you have to pass it back the same cookie.::
554
+
555
+    200 OK
556
+    Set-Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="; Path=/; HttpOnly
557
+
558
+Next request::
559
+
560
+    GET /(...)
561
+    Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="
562
+
563
+
564
+7.0 Document Version
565
+---------------------
566
+
567
+- 1.0 : May 6th 2013 : initial release 
568
+- 1.1 : June 1st 2013 : Added Delete Repository and way to handle new source namespace.
0 569
\ No newline at end of file