Browse code

Minor style cleanups to the API spec docs

James Turnbull authored on 2013/12/24 01:45:51
Showing 2 changed files
... ...
@@ -19,7 +19,8 @@ Docker Registry API
19 19
 - It doesn’t have a local database
20 20
 - It will be open-sourced at some point
21 21
 
22
-We expect that there will be multiple registries out there. To help to grasp the context, here are some examples of registries:
22
+We expect that there will be multiple registries out there. To help to grasp
23
+the context, here are some examples of registries:
23 24
 
24 25
 - **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.
25 26
 - **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.
... ...
@@ -37,7 +38,10 @@ We expect that there will be multiple registries out there. To help to grasp the
37 37
         - local mount point;
38 38
         - remote docker addressed through SSH.
39 39
 
40
-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).
40
+The latter would only require two new commands in docker, e.g. ``registryget``
41
+and ``registryput``, wrapping access to the local filesystem (and optionally
42
+doing consistency checks). Authentication and authorization are then delegated
43
+to SSH (e.g. with public keys).
41 44
 
42 45
 2. Endpoints
43 46
 ============
... ...
@@ -15,11 +15,13 @@ Registry & Index Spec
15 15
 ---------
16 16
 
17 17
 The Index is responsible for centralizing information about:
18
+
18 19
 - User accounts
19 20
 - Checksums of the images
20 21
 - Public namespaces
21 22
 
22 23
 The Index has different components:
24
+
23 25
 - Web UI
24 26
 - Meta-data store (comments, stars, list public repositories)
25 27
 - Authentication service
... ...
@@ -27,7 +29,7 @@ The Index has different components:
27 27
 
28 28
 The index is authoritative for those information.
29 29
 
30
-We expect that there will be only one instance of the index, run and managed by dotCloud.
30
+We expect that there will be only one instance of the index, run and managed by Docker Inc.
31 31
 
32 32
 1.2 Registry
33 33
 ------------
... ...
@@ -53,12 +55,16 @@ We expect that there will be multiple registries out there. To help to grasp the
53 53
         - local mount point;
54 54
         - remote docker addressed through SSH.
55 55
 
56
-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).
56
+The latter would only require two new commands in docker, e.g. ``registryget``
57
+and ``registryput``, wrapping access to the local filesystem (and optionally
58
+doing consistency checks). Authentication and authorization are then delegated
59
+to SSH (e.g. with public keys).
57 60
 
58 61
 1.3 Docker
59 62
 ----------
60 63
 
61 64
 On top of being a runtime for LXC, Docker is the Registry client. It supports:
65
+
62 66
 - Push / Pull on the registry
63 67
 - Client authentication on the Index
64 68
 
... ...
@@ -72,21 +78,33 @@ On top of being a runtime for LXC, Docker is the Registry client. It supports:
72 72
 
73 73
 1. Contact the Index to know where I should download “samalba/busybox”
74 74
 2. Index replies:
75
-   a. “samalba/busybox” is on Registry A
76
-   b. here are the checksums for “samalba/busybox” (for all layers)
75
+   a. ``samalba/busybox`` is on Registry A
76
+   b. here are the checksums for ``samalba/busybox`` (for all layers)
77 77
    c. token
78
-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.
78
+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.
79 79
 4. registry contacts index to verify if token/user is allowed to download images
80 80
 5. Index returns true/false lettings registry know if it should proceed or error out
81 81
 6. Get the payload for all layers
82 82
 
83
-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.
83
+It's possible to run:
84
+
85
+.. code-block:: bash
86
+
87
+    docker pull https://<registry>/repositories/samalba/busybox
88
+
89
+In this case, Docker bypasses the Index. However the security is not guaranteed
90
+(in case Registry A is corrupted) because there won’t be any checksum checks.
84 91
 
85
-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.
92
+Currently registry redirects to s3 urls for downloads, going forward all
93
+downloads need to be streamed through the registry. The Registry will then
94
+abstract the calls to S3 by a top-level class which implements sub-classes for
95
+S3 and local storage.
86 96
 
87
-Token is only returned when the 'X-Docker-Token' header is sent with request.
97
+Token is only returned when the ``X-Docker-Token`` header is sent with request.
88 98
 
89
-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.
99
+Basic Auth is required to pull private repos. Basic auth isn't required for
100
+pulling public repos, but if one is provided, it needs to be valid and for an
101
+active account.
90 102
 
91 103
 API (pulling repository foo/bar):
92 104
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
@@ -155,7 +173,9 @@ API (pulling repository foo/bar):
155 155
 
156 156
     **Index can be replaced!** For a private Registry deployed, a custom Index can be used to serve and validate token according to different policies.
157 157
 
158
-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).
158
+Docker computes the checksums and submit them to the Index at the end of the
159
+push. When a repository name does not have checksums on the Index, it means
160
+that the push is in progress (since checksums are submitted at the end).
159 161
 
160 162
 API (pushing repos foo/bar):
161 163
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
@@ -237,10 +257,11 @@ API (pushing repos foo/bar):
237 237
 2.3 Delete
238 238
 ----------
239 239
 
240
-If you need to delete something from the index or registry, we need a nice clean way to do that. Here is the workflow.
240
+If you need to delete something from the index or registry, we need a nice
241
+clean way to do that. Here is the workflow.
241 242
 
242
-1. Docker contacts the index to request a delete of a repository “samalba/busybox” (authentication required with user credentials)
243
-2. If authentication works and repository is valid, “samalba/busybox” is marked as deleted and a temporary token is returned
243
+1. Docker contacts the index to request a delete of a repository ``samalba/busybox`` (authentication required with user credentials)
244
+2. If authentication works and repository is valid, ``samalba/busybox`` is marked as deleted and a temporary token is returned
244 245
 3. Send a delete request to the registry for the repository (along with the token)
245 246
 4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
246 247
 5. Index validates the token. Registry A deletes the repository and everything associated to it.
... ...
@@ -312,24 +333,40 @@ The Index has two main purposes (along with its fancy social features):
312 312
 
313 313
 3.1 Without an Index
314 314
 --------------------
315
-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.
316 315
 
317
-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...).
316
+Using the Registry without the Index can be useful to store the images on a
317
+private network without having to rely on an external entity controlled by
318
+Docker Inc.
318 319
 
319
-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.
320
+In this case, the registry will be launched in a special mode (--standalone?
321
+--no-index?). In this mode, the only thing which changes is that Registry will
322
+never contact the Index to verify a token. It will be the Registry owner
323
+responsibility to authenticate the user who pushes (or even pulls) an image
324
+using any mechanism (HTTP auth, IP based, etc...).
320 325
 
321
-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
+In this scenario, the Registry is responsible for the security in case of data
327
+corruption since the checksums are not delivered by a trusted entity.
328
+
329
+As hinted previously, a standalone registry can also be implemented by any HTTP
330
+server handling GET/PUT requests (or even only GET requests if no write access
331
+is necessary).
322 332
 
323 333
 3.2 With an Index
324 334
 -----------------
325 335
 
326 336
 The Index data needed by the Registry are simple:
337
+
327 338
 - Serve the checksums
328 339
 - Provide and authorize a Token
329 340
 
330
-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.
341
+In the scenario of a Registry running on a private network with the need of
342
+centralizing and authorizing, it’s easy to use a custom Index.
331 343
 
332
-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.
344
+The only challenge will be to tell Docker to contact (and trust) this custom
345
+Index. Docker will be configurable at some point to use a specific Index, it’ll
346
+be the private entity responsibility (basically the organization who uses
347
+Docker in a private environment) to maintain the Index and the Docker’s
348
+configuration among its consumers.
333 349
 
334 350
 4. The API
335 351
 ==========
... ...
@@ -339,16 +376,22 @@ The first version of the api is available here: https://github.com/jpetazzo/dock
339 339
 4.1 Images
340 340
 ----------
341 341
 
342
-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.
342
+The format returned in the images is not defined here (for layer and JSON),
343
+basically because Registry stores exactly the same kind of information as
344
+Docker uses to manage them.
345
+
346
+The format of ancestry is a line-separated list of image ids, in age order,
347
+i.e. the image’s parent is on the last line, the parent of the parent on the
348
+next-to-last line, etc.; if the image has no parent, the file is empty.
343 349
 
344
-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.
350
+.. code-block:: bash
345 351
 
346
-GET /v1/images/<image_id>/layer
347
-PUT /v1/images/<image_id>/layer
348
-GET /v1/images/<image_id>/json
349
-PUT /v1/images/<image_id>/json
350
-GET /v1/images/<image_id>/ancestry
351
-PUT /v1/images/<image_id>/ancestry
352
+    GET /v1/images/<image_id>/layer
353
+    PUT /v1/images/<image_id>/layer
354
+    GET /v1/images/<image_id>/json
355
+    PUT /v1/images/<image_id>/json
356
+    GET /v1/images/<image_id>/ancestry
357
+    PUT /v1/images/<image_id>/ancestry
352 358
 
353 359
 4.2 Users
354 360
 ---------
... ...
@@ -393,7 +436,9 @@ PUT /v1/users/<username>
393 393
 
394 394
 4.2.3 Login (Index)
395 395
 ^^^^^^^^^^^^^^^^^^^
396
-Does nothing else but asking for a user authentication. Can be used to validate credentials. HTTP Basic Auth for now, maybe change in future.
396
+
397
+Does nothing else but asking for a user authentication. Can be used to validate
398
+credentials. HTTP Basic Auth for now, maybe change in future.
397 399
 
398 400
 GET /v1/users
399 401
 
... ...
@@ -405,7 +450,10 @@ GET /v1/users
405 405
 4.3 Tags (Registry)
406 406
 -------------------
407 407
 
408
-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.
408
+The Registry does not know anything about users. Even though repositories are
409
+under usernames, it’s just a namespace for the registry. Allowing us to
410
+implement organizations or different namespaces per user later, without
411
+modifying the Registry’s API.
409 412
 
410 413
 The following naming restrictions apply:
411 414
 
... ...
@@ -439,7 +487,10 @@ DELETE /v1/repositories/<namespace>/<repo_name>/tags/<tag>
439 439
 4.4 Images (Index)
440 440
 ------------------
441 441
 
442
-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.
442
+For the Index to “resolve” the repository name to a Registry location, it uses
443
+the X-Docker-Endpoints header. In other terms, this requests always add a
444
+``X-Docker-Endpoints`` to indicate the location of the registry which hosts this
445
+repository.
443 446
 
444 447
 4.4.1 Get the images
445 448
 ^^^^^^^^^^^^^^^^^^^^^
... ...
@@ -484,17 +535,20 @@ Return 202 OK
484 484
 ======================
485 485
 
486 486
 It’s possible to chain Registries server for several reasons:
487
+
487 488
 - Load balancing
488 489
 - Delegate the next request to another server
489 490
 
490
-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.
491
+When a Registry is a reference for a repository, it should host the entire
492
+images chain in order to avoid breaking the chain during the download.
491 493
 
492 494
 The Index and Registry use this mechanism to redirect on one or the other.
493 495
 
494 496
 Example with an image download:
495
-On every request, a special header can be returned:
496 497
 
497
-X-Docker-Endpoints: server1,server2
498
+On every request, a special header can be returned::
499
+
500
+    X-Docker-Endpoints: server1,server2
498 501
 
499 502
 On the next request, the client will always pick a server from this list.
500 503
 
... ...
@@ -504,7 +558,8 @@ On the next request, the client will always pick a server from this list.
504 504
 6.1 On the Index
505 505
 -----------------
506 506
 
507
-The Index supports both “Basic” and “Token” challenges. Usually when there is a “401 Unauthorized”, the Index replies this::
507
+The Index supports both “Basic” and “Token” challenges. Usually when there is a
508
+``401 Unauthorized``, the Index replies this::
508 509
 
509 510
     401 Unauthorized
510 511
     WWW-Authenticate: Basic realm="auth required",Token
... ...
@@ -543,11 +598,13 @@ The Registry only supports the Token challenge::
543 543
     401 Unauthorized
544 544
     WWW-Authenticate: Token
545 545
 
546
-The only way is to provide a token on “401 Unauthorized” responses::
546
+The only way is to provide a token on ``401 Unauthorized`` responses::
547 547
 
548
-    Authorization: Token signature=123abc,repository=”foo/bar”,access=read
548
+    Authorization: Token signature=123abc,repository="foo/bar",access=read
549 549
 
550
-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.::
550
+Usually, the Registry provides a Cookie when a Token verification succeeded.
551
+Every time the Registry passes a Cookie, you have to pass it back the same
552
+cookie.::
551 553
 
552 554
     200 OK
553 555
     Set-Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="; Path=/; HttpOnly