github.com/mika/distribution@v2.2.2-0.20160108133430-a75790e3d8e0+incompatible/docs/spec/api.md.tmpl (about) 1 <!--[metadata]> 2 +++ 3 title = "HTTP API V2" 4 description = "Specification for the Registry API." 5 keywords = ["registry, on-prem, images, tags, repository, distribution, api, advanced"] 6 [menu.main] 7 parent="smn_registry_ref" 8 +++ 9 <![end-metadata]--> 10 11 # Docker Registry HTTP API V2 12 13 ## Introduction 14 15 The _Docker Registry HTTP API_ is the protocol to facilitate distribution of 16 images to the docker engine. It interacts with instances of the docker 17 registry, which is a service to manage information about docker images and 18 enable their distribution. The specification covers the operation of version 2 19 of this API, known as _Docker Registry HTTP API V2_. 20 21 While the V1 registry protocol is usable, there are several problems with the 22 architecture that have led to this new version. The main driver of this 23 specification these changes to the docker the image format, covered in 24 [docker/docker#8093](https://github.com/docker/docker/issues/8093). The new, self-contained image manifest simplifies image 25 definition and improves security. This specification will build on that work, 26 leveraging new properties of the manifest format to improve performance, 27 reduce bandwidth usage and decrease the likelihood of backend corruption. 28 29 For relevant details and history leading up to this specification, please see 30 the following issues: 31 32 - [docker/docker#8093](https://github.com/docker/docker/issues/8093) 33 - [docker/docker#9015](https://github.com/docker/docker/issues/9015) 34 - [docker/docker-registry#612](https://github.com/docker/docker-registry/issues/612) 35 36 ### Scope 37 38 This specification covers the URL layout and protocols of the interaction 39 between docker registry and docker core. This will affect the docker core 40 registry API and the rewrite of docker-registry. Docker registry 41 implementations may implement other API endpoints, but they are not covered by 42 this specification. 43 44 This includes the following features: 45 46 - Namespace-oriented URI Layout 47 - PUSH/PULL registry server for V2 image manifest format 48 - Resumable layer PUSH support 49 - V2 Client library implementation 50 51 While authentication and authorization support will influence this 52 specification, details of the protocol will be left to a future specification. 53 Relevant header definitions and error codes are present to provide an 54 indication of what a client may encounter. 55 56 #### Future 57 58 There are features that have been discussed during the process of cutting this 59 specification. The following is an incomplete list: 60 61 - Immutable image references 62 - Multiple architecture support 63 - Migration from v2compatibility representation 64 65 These may represent features that are either out of the scope of this 66 specification, the purview of another specification or have been deferred to a 67 future version. 68 69 ### Use Cases 70 71 For the most part, the use cases of the former registry API apply to the new 72 version. Differentiating use cases are covered below. 73 74 #### Image Verification 75 76 A docker engine instance would like to run verified image named 77 "library/ubuntu", with the tag "latest". The engine contacts the registry, 78 requesting the manifest for "library/ubuntu:latest". An untrusted registry 79 returns a manifest. Before proceeding to download the individual layers, the 80 engine verifies the manifest's signature, ensuring that the content was 81 produced from a trusted source and no tampering has occured. After each layer 82 is downloaded, the engine verifies the digest of the layer, ensuring that the 83 content matches that specified by the manifest. 84 85 #### Resumable Push 86 87 Company X's build servers lose connectivity to docker registry before 88 completing an image layer transfer. After connectivity returns, the build 89 server attempts to re-upload the image. The registry notifies the build server 90 that the upload has already been partially attempted. The build server 91 responds by only sending the remaining data to complete the image file. 92 93 #### Resumable Pull 94 95 Company X is having more connectivity problems but this time in their 96 deployment datacenter. When downloading an image, the connection is 97 interrupted before completion. The client keeps the partial data and uses http 98 `Range` requests to avoid downloading repeated data. 99 100 #### Layer Upload De-duplication 101 102 Company Y's build system creates two identical docker layers from build 103 processes A and B. Build process A completes uploading the layer before B. 104 When process B attempts to upload the layer, the registry indicates that its 105 not necessary because the layer is already known. 106 107 If process A and B upload the same layer at the same time, both operations 108 will proceed and the first to complete will be stored in the registry (Note: 109 we may modify this to prevent dogpile with some locking mechanism). 110 111 ### Changes 112 113 The V2 specification has been written to work as a living document, specifying 114 only what is certain and leaving what is not specified open or to future 115 changes. Only non-conflicting additions should be made to the API and accepted 116 changes should avoid preventing future changes from happening. 117 118 This section should be updated when changes are made to the specification, 119 indicating what is different. Optionally, we may start marking parts of the 120 specification to correspond with the versions enumerated here. 121 122 Each set of changes is given a letter corresponding to a set of modifications 123 that were applied to the baseline specification. These are merely for 124 reference and shouldn't be used outside the specification other than to 125 identify a set of modifications. 126 127 <dl> 128 <dt>f</dt> 129 <dd> 130 <ul> 131 <li>Specify the delete API for layers and manifests.</li> 132 </ul> 133 </dd> 134 135 <dt>e</dt> 136 <dd> 137 <ul> 138 <li>Added support for listing registry contents.</li> 139 <li>Added pagination to tags API.</li> 140 <li>Added common approach to support pagination.</li> 141 </ul> 142 </dd> 143 144 <dt>d</dt> 145 <dd> 146 <ul> 147 <li>Allow repository name components to be one character.</li> 148 <li>Clarified that single component names are allowed.</li> 149 </ul> 150 </dd> 151 152 <dt>c</dt> 153 <dd> 154 <ul> 155 <li>Added section covering digest format.</li> 156 <li>Added more clarification that manifest cannot be deleted by tag.</li> 157 </ul> 158 </dd> 159 160 <dt>b</dt> 161 <dd> 162 <ul> 163 <li>Added capability of doing streaming upload to PATCH blob upload.</li> 164 <li>Updated PUT blob upload to no longer take final chunk, now requires entire data or no data.</li> 165 <li>Removed `416 Requested Range Not Satisfiable` response status from PUT blob upload.</li> 166 </ul> 167 </dd> 168 169 <dt>a</dt> 170 <dd> 171 <ul> 172 <li>Added support for immutable manifest references in manifest endpoints.</li> 173 <li>Deleting a manifest by tag has been deprecated.</li> 174 <li>Specified `Docker-Content-Digest` header for appropriate entities.</li> 175 <li>Added error code for unsupported operations.</li> 176 </ul> 177 </dd> 178 </dl> 179 180 ## Overview 181 182 This section covers client flows and details of the API endpoints. The URI 183 layout of the new API is structured to support a rich authentication and 184 authorization model by leveraging namespaces. All endpoints will be prefixed 185 by the API version and the repository name: 186 187 /v2/<name>/ 188 189 For example, an API endpoint that will work with the `library/ubuntu` 190 repository, the URI prefix will be: 191 192 /v2/library/ubuntu/ 193 194 This scheme provides rich access control over various operations and methods 195 using the URI prefix and http methods that can be controlled in variety of 196 ways. 197 198 Classically, repository names have always been two path components where each 199 path component is less than 30 characters. The V2 registry API does not 200 enforce this. The rules for a repository name are as follows: 201 202 1. A repository name is broken up into _path components_. A component of a 203 repository name must be at least one lowercase, alpha-numeric characters, 204 optionally separated by periods, dashes or underscores. More strictly, it 205 must match the regular expression `[a-z0-9]+(?:[._-][a-z0-9]+)*`. 206 2. If a repository name has two or more path components, they must be 207 separated by a forward slash ("/"). 208 3. The total length of a repository name, including slashes, must be less the 209 256 characters. 210 211 These name requirements _only_ apply to the registry API and should accept a 212 superset of what is supported by other docker ecosystem components. 213 214 All endpoints should support aggressive http caching, compression and range 215 headers, where appropriate. The new API attempts to leverage HTTP semantics 216 where possible but may break from standards to implement targeted features. 217 218 For detail on individual endpoints, please see the [_Detail_](#detail) 219 section. 220 221 ### Errors 222 223 Actionable failure conditions, covered in detail in their relevant sections, 224 are reported as part of 4xx responses, in a json response body. One or more 225 errors will be returned in the following format: 226 227 { 228 "errors:" [{ 229 "code": <error identifier>, 230 "message": <message describing condition>, 231 "detail": <unstructured> 232 }, 233 ... 234 ] 235 } 236 237 The `code` field will be a unique identifier, all caps with underscores by 238 convention. The `message` field will be a human readable string. The optional 239 `detail` field may contain arbitrary json data providing information the 240 client can use to resolve the issue. 241 242 While the client can take action on certain error codes, the registry may add 243 new error codes over time. All client implementations should treat unknown 244 error codes as `UNKNOWN`, allowing future error codes to be added without 245 breaking API compatibility. For the purposes of the specification error codes 246 will only be added and never removed. 247 248 For a complete account of all error codes, please see the _Detail_ section. 249 250 ### API Version Check 251 252 A minimal endpoint, mounted at `/v2/` will provide version support information 253 based on its response statuses. The request format is as follows: 254 255 GET /v2/ 256 257 If a `200 OK` response is returned, the registry implements the V2(.1) 258 registry API and the client may proceed safely with other V2 operations. 259 Optionally, the response may contain information about the supported paths in 260 the response body. The client should be prepared to ignore this data. 261 262 If a `401 Unauthorized` response is returned, the client should take action 263 based on the contents of the "WWW-Authenticate" header and try the endpoint 264 again. Depending on access control setup, the client may still have to 265 authenticate against different resources, even if this check succeeds. 266 267 If `404 Not Found` response status, or other unexpected status, is returned, 268 the client should proceed with the assumption that the registry does not 269 implement V2 of the API. 270 271 When a `200 OK` or `401 Unauthorized` response is returned, the 272 "Docker-Distribution-API-Version" header should be set to "registry/2.0". 273 Clients may require this header value to determine if the endpoint serves this 274 API. When this header is omitted, clients may fallback to an older API version. 275 276 ### Content Digests 277 278 This API design is driven heavily by [content addressability](http://en.wikipedia.org/wiki/Content-addressable_storage). 279 The core of this design is the concept of a content addressable identifier. It 280 uniquely identifies content by taking a collision-resistant hash of the bytes. 281 Such an identifier can be independently calculated and verified by selection 282 of a common _algorithm_. If such an identifier can be communicated in a secure 283 manner, one can retrieve the content from an insecure source, calculate it 284 independently and be certain that the correct content was obtained. Put simply, 285 the identifier is a property of the content. 286 287 To disambiguate from other concepts, we call this identifier a _digest_. A 288 _digest_ is a serialized hash result, consisting of a _algorithm_ and _hex_ 289 portion. The _algorithm_ identifies the methodology used to calculate the 290 digest. The _hex_ portion is the hex-encoded result of the hash. 291 292 We define a _digest_ string to match the following grammar: 293 ``` 294 digest := algorithm ":" hex 295 algorithm := /[A-Fa-f0-9_+.-]+/ 296 hex := /[A-Fa-f0-9]+/ 297 ``` 298 299 Some examples of _digests_ include the following: 300 301 digest | description | 302 ----------------------------------------------------------------------------------|------------------------------------------------ 303 sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b | Common sha256 based digest | 304 305 While the _algorithm_ does allow one to implement a wide variety of 306 algorithms, compliant implementations should use sha256. Heavy processing of 307 input before calculating a hash is discouraged to avoid degrading the 308 uniqueness of the _digest_ but some canonicalization may be performed to 309 ensure consistent identifiers. 310 311 Let's use a simple example in pseudo-code to demonstrate a digest calculation: 312 ``` 313 let C = 'a small string' 314 let B = sha256(C) 315 let D = 'sha256:' + EncodeHex(B) 316 let ID(C) = D 317 ``` 318 319 Above, we have bytestring `C` passed into a function, `SHA256`, that returns a 320 bytestring `B`, which is the hash of `C`. `D` gets the algorithm concatenated 321 with the hex encoding of `B`. We then define the identifier of `C` to `ID(C)` 322 as equal to `D`. A digest can be verified by independently calculating `D` and 323 comparing it with identifier `ID(C)`. 324 325 #### Digest Header 326 327 To provide verification of http content, any response may include a `Docker- 328 Content-Digest` header. This will include the digest of the target entity 329 returned in the response. For blobs, this is the entire blob content. For 330 manifests, this is the manifest body without the signature content, also known 331 as the JWS payload. Note that the commonly used canonicalization for digest 332 calculation may be dependent on the mediatype of the content, such as with 333 manifests. 334 335 The client may choose to ignore the header or may verify it to ensure content 336 integrity and transport security. This is most important when fetching by a 337 digest. To ensure security, the content should be verified against the digest 338 used to fetch the content. At times, the returned digest may differ from that 339 used to initiate a request. Such digests are considered to be from different 340 _domains_, meaning they have different values for _algorithm_. In such a case, 341 the client may choose to verify the digests in both domains or ignore the 342 server's digest. To maintain security, the client _must_ always verify the 343 content against the _digest_ used to fetch the content. 344 345 > __IMPORTANT:__ If a _digest_ is used to fetch content, the client should use 346 > the same digest used to fetch the content to verify it. The header `Docker- 347 > Content-Digest` should not be trusted over the "local" digest. 348 349 ### Pulling An Image 350 351 An "image" is a combination of a JSON manifest and individual layer files. The 352 process of pulling an image centers around retrieving these two components. 353 354 The first step in pulling an image is to retrieve the manifest. For reference, 355 the relevant manifest fields for the registry are the following: 356 357 field | description | 358 ----------|------------------------------------------------| 359 name | The name of the image. | 360 tag | The tag for this version of the image. | 361 fsLayers | A list of layer descriptors (including digest) | 362 signature | A JWS used to verify the manifest content | 363 364 For more information about the manifest format, please see 365 [docker/docker#8093](https://github.com/docker/docker/issues/8093). 366 367 When the manifest is in hand, the client must verify the signature to ensure 368 the names and layers are valid. Once confirmed, the client will then use the 369 digests to download the individual layers. Layers are stored in as blobs in 370 the V2 registry API, keyed by their digest. 371 372 #### Pulling an Image Manifest 373 374 The image manifest can be fetched with the following url: 375 376 ``` 377 GET /v2/<name>/manifests/<reference> 378 ``` 379 380 The `name` and `reference` parameter identify the image and are required. The 381 reference may include a tag or digest. 382 383 A `404 Not Found` response will be returned if the image is unknown to the 384 registry. If the image exists and the response is successful, the image 385 manifest will be returned, with the following format (see docker/docker#8093 386 for details): 387 388 { 389 "name": <name>, 390 "tag": <tag>, 391 "fsLayers": [ 392 { 393 "blobSum": <digest> 394 }, 395 ... 396 ] 397 ], 398 "history": <v1 images>, 399 "signature": <JWS> 400 } 401 402 The client should verify the returned manifest signature for authenticity 403 before fetching layers. 404 405 ##### Existing Manifests 406 407 The image manifest can be checked for existence with the following url: 408 409 ``` 410 HEAD /v2/<name>/manifests/<reference> 411 ``` 412 413 The `name` and `reference` parameter identify the image and are required. The 414 reference may include a tag or digest. 415 416 A `404 Not Found` response will be returned if the image is unknown to the 417 registry. If the image exists and the response is successful the response will 418 be as follows: 419 420 ``` 421 200 OK 422 Content-Length: <length of manifest> 423 Docker-Content-Digest: <digest> 424 ``` 425 426 427 #### Pulling a Layer 428 429 Layers are stored in the blob portion of the registry, keyed by digest. 430 Pulling a layer is carried out by a standard http request. The URL is as 431 follows: 432 433 GET /v2/<name>/blobs/<digest> 434 435 Access to a layer will be gated by the `name` of the repository but is 436 identified uniquely in the registry by `digest`. 437 438 This endpoint may issue a 307 (302 for <HTTP 1.1) redirect to another service 439 for downloading the layer and clients should be prepared to handle redirects. 440 441 This endpoint should support aggressive HTTP caching for image layers. Support 442 for Etags, modification dates and other cache control headers should be 443 included. To allow for incremental downloads, `Range` requests should be 444 supported, as well. 445 446 ### Pushing An Image 447 448 Pushing an image works in the opposite order as a pull. After assembling the 449 image manifest, the client must first push the individual layers. When the 450 layers are fully pushed into the registry, the client should upload the signed 451 manifest. 452 453 The details of each step of the process are covered in the following sections. 454 455 #### Pushing a Layer 456 457 All layer uploads use two steps to manage the upload process. The first step 458 starts the upload in the registry service, returning a url to carry out the 459 second step. The second step uses the upload url to transfer the actual data. 460 Uploads are started with a POST request which returns a url that can be used 461 to push data and check upload status. 462 463 The `Location` header will be used to communicate the upload location after 464 each request. While it won't change in the this specification, clients should 465 use the most recent value returned by the API. 466 467 ##### Starting An Upload 468 469 To begin the process, a POST request should be issued in the following format: 470 471 ``` 472 POST /v2/<name>/blobs/uploads/ 473 ``` 474 475 The parameters of this request are the image namespace under which the layer 476 will be linked. Responses to this request are covered below. 477 478 ##### Existing Layers 479 480 The existence of a layer can be checked via a `HEAD` request to the blob store 481 API. The request should be formatted as follows: 482 483 ``` 484 HEAD /v2/<name>/blobs/<digest> 485 ``` 486 487 If the layer with the digest specified in `digest` is available, a 200 OK 488 response will be received, with no actual body content (this is according to 489 http specification). The response will look as follows: 490 491 ``` 492 200 OK 493 Content-Length: <length of blob> 494 Docker-Content-Digest: <digest> 495 ``` 496 497 When this response is received, the client can assume that the layer is 498 already available in the registry under the given name and should take no 499 further action to upload the layer. Note that the binary digests may differ 500 for the existing registry layer, but the digests will be guaranteed to match. 501 502 ##### Uploading the Layer 503 504 If the POST request is successful, a `202 Accepted` response will be returned 505 with the upload URL in the `Location` header: 506 507 ``` 508 202 Accepted 509 Location: /v2/<name>/blobs/uploads/<uuid> 510 Range: bytes=0-<offset> 511 Content-Length: 0 512 Docker-Upload-UUID: <uuid> 513 ``` 514 515 The rest of the upload process can be carried out with the returned url, 516 called the "Upload URL" from the `Location` header. All responses to the 517 upload url, whether sending data or getting status, will be in this format. 518 Though the URI format (`/v2/<name>/blobs/uploads/<uuid>`) for the `Location` 519 header is specified, clients should treat it as an opaque url and should never 520 try to assemble the it. While the `uuid` parameter may be an actual UUID, this 521 proposal imposes no constraints on the format and clients should never impose 522 any. 523 524 If clients need to correlate local upload state with remote upload state, the 525 contents of the `Docker-Upload-UUID` header should be used. Such an id can be 526 used to key the last used location header when implementing resumable uploads. 527 528 ##### Upload Progress 529 530 The progress and chunk coordination of the upload process will be coordinated 531 through the `Range` header. While this is a non-standard use of the `Range` 532 header, there are examples of [similar approaches](https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol) in APIs with heavy use. 533 For an upload that just started, for an example with a 1000 byte layer file, 534 the `Range` header would be as follows: 535 536 ``` 537 Range: bytes=0-0 538 ``` 539 540 To get the status of an upload, issue a GET request to the upload URL: 541 542 ``` 543 GET /v2/<name>/blobs/uploads/<uuid> 544 Host: <registry host> 545 ``` 546 547 The response will be similar to the above, except will return 204 status: 548 549 ``` 550 204 No Content 551 Location: /v2/<name>/blobs/uploads/<uuid> 552 Range: bytes=0-<offset> 553 Docker-Upload-UUID: <uuid> 554 ``` 555 556 Note that the HTTP `Range` header byte ranges are inclusive and that will be 557 honored, even in non-standard use cases. 558 559 ##### Monolithic Upload 560 561 A monolithic upload is simply a chunked upload with a single chunk and may be 562 favored by clients that would like to avoided the complexity of chunking. To 563 carry out a "monolithic" upload, one can simply put the entire content blob to 564 the provided URL: 565 566 ``` 567 PUT /v2/<name>/blobs/uploads/<uuid>?digest=<digest> 568 Content-Length: <size of layer> 569 Content-Type: application/octet-stream 570 571 <Layer Binary Data> 572 ``` 573 574 The "digest" parameter must be included with the PUT request. Please see the 575 _Completed Upload_ section for details on the parameters and expected 576 responses. 577 578 Additionally, the upload can be completed with a single `POST` request to 579 the uploads endpoint, including the "size" and "digest" parameters: 580 581 ``` 582 POST /v2/<name>/blobs/uploads/?digest=<digest> 583 Content-Length: <size of layer> 584 Content-Type: application/octet-stream 585 586 <Layer Binary Data> 587 ``` 588 589 On the registry service, this should allocate a download, accept and verify 590 the data and return the same response as the final chunk of an upload. If the 591 POST request fails collecting the data in any way, the registry should attempt 592 to return an error response to the client with the `Location` header providing 593 a place to continue the download. 594 595 The single `POST` method is provided for convenience and most clients should 596 implement `POST` + `PUT` to support reliable resume of uploads. 597 598 ##### Chunked Upload 599 600 To carry out an upload of a chunk, the client can specify a range header and 601 only include that part of the layer file: 602 603 ``` 604 PATCH /v2/<name>/blobs/uploads/<uuid> 605 Content-Length: <size of chunk> 606 Content-Range: <start of range>-<end of range> 607 Content-Type: application/octet-stream 608 609 <Layer Chunk Binary Data> 610 ``` 611 612 There is no enforcement on layer chunk splits other than that the server must 613 receive them in order. The server may enforce a minimum chunk size. If the 614 server cannot accept the chunk, a `416 Requested Range Not Satisfiable` 615 response will be returned and will include a `Range` header indicating the 616 current status: 617 618 ``` 619 416 Requested Range Not Satisfiable 620 Location: /v2/<name>/blobs/uploads/<uuid> 621 Range: 0-<last valid range> 622 Content-Length: 0 623 Docker-Upload-UUID: <uuid> 624 ``` 625 626 If this response is received, the client should resume from the "last valid 627 range" and upload the subsequent chunk. A 416 will be returned under the 628 following conditions: 629 630 - Invalid Content-Range header format 631 - Out of order chunk: the range of the next chunk must start immediately after 632 the "last valid range" from the previous response. 633 634 When a chunk is accepted as part of the upload, a `202 Accepted` response will 635 be returned, including a `Range` header with the current upload status: 636 637 ``` 638 202 Accepted 639 Location: /v2/<name>/blobs/uploads/<uuid> 640 Range: bytes=0-<offset> 641 Content-Length: 0 642 Docker-Upload-UUID: <uuid> 643 ``` 644 645 ##### Completed Upload 646 647 For an upload to be considered complete, the client must submit a `PUT` 648 request on the upload endpoint with a digest parameter. If it is not provided, 649 the upload will not be considered complete. The format for the final chunk 650 will be as follows: 651 652 ``` 653 PUT /v2/<name>/blob/uploads/<uuid>?digest=<digest> 654 Content-Length: <size of chunk> 655 Content-Range: <start of range>-<end of range> 656 Content-Type: application/octet-stream 657 658 <Last Layer Chunk Binary Data> 659 ``` 660 661 Optionally, if all chunks have already been uploaded, a `PUT` request with a 662 `digest` parameter and zero-length body may be sent to complete and validated 663 the upload. Multiple "digest" parameters may be provided with different 664 digests. The server may verify none or all of them but _must_ notify the 665 client if the content is rejected. 666 667 When the last chunk is received and the layer has been validated, the client 668 will receive a `201 Created` response: 669 670 ``` 671 201 Created 672 Location: /v2/<name>/blobs/<digest> 673 Content-Length: 0 674 Docker-Content-Digest: <digest> 675 ``` 676 677 The `Location` header will contain the registry URL to access the accepted 678 layer file. The `Docker-Content-Digest` header returns the canonical digest of 679 the uploaded blob which may differ from the provided digest. Most clients may 680 ignore the value but if it is used, the client should verify the value against 681 the uploaded blob data. 682 683 ###### Digest Parameter 684 685 The "digest" parameter is designed as an opaque parameter to support 686 verification of a successful transfer. For example, a HTTP URI parameter 687 might be as follows: 688 689 ``` 690 sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b 691 ``` 692 693 Given this parameter, the registry will verify that the provided content does 694 match this digest. 695 696 ##### Canceling an Upload 697 698 An upload can be cancelled by issuing a DELETE request to the upload endpoint. 699 The format will be as follows: 700 701 ``` 702 DELETE /v2/<name>/blobs/uploads/<uuid> 703 ``` 704 705 After this request is issued, the upload uuid will no longer be valid and the 706 registry server will dump all intermediate data. While uploads will time out 707 if not completed, clients should issue this request if they encounter a fatal 708 error but still have the ability to issue an http request. 709 710 ##### Errors 711 712 If an 502, 503 or 504 error is received, the client should assume that the 713 download can proceed due to a temporary condition, honoring the appropriate 714 retry mechanism. Other 5xx errors should be treated as terminal. 715 716 If there is a problem with the upload, a 4xx error will be returned indicating 717 the problem. After receiving a 4xx response (except 416, as called out above), 718 the upload will be considered failed and the client should take appropriate 719 action. 720 721 Note that the upload url will not be available forever. If the upload uuid is 722 unknown to the registry, a `404 Not Found` response will be returned and the 723 client must restart the upload process. 724 725 ### Deleting a Layer 726 727 A layer may be deleted from the registry via its `name` and `digest`. A 728 delete may be issued with the following request format: 729 730 DELETE /v2/<name>/blobs/<digest> 731 732 If the blob exists and has been successfully deleted, the following response 733 will be issued: 734 735 202 Accepted 736 Content-Length: None 737 738 If the blob had already been deleted or did not exist, a `404 Not Found` 739 response will be issued instead. 740 741 If a layer is deleted which is referenced by a manifest in the registry, 742 then the complete images will not be resolvable. 743 744 #### Pushing an Image Manifest 745 746 Once all of the layers for an image are uploaded, the client can upload the 747 image manifest. An image can be pushed using the following request format: 748 749 PUT /v2/<name>/manifests/<reference> 750 751 { 752 "name": <name>, 753 "tag": <tag>, 754 "fsLayers": [ 755 { 756 "blobSum": <digest> 757 }, 758 ... 759 ] 760 ], 761 "history": <v1 images>, 762 "signature": <JWS>, 763 ... 764 } 765 766 The `name` and `reference` fields of the response body must match those specified in 767 the URL. The `reference` field may be a "tag" or a "digest". 768 769 If there is a problem with pushing the manifest, a relevant 4xx response will 770 be returned with a JSON error message. Please see the _PUT Manifest section 771 for details on possible error codes that may be returned. 772 773 If one or more layers are unknown to the registry, `BLOB_UNKNOWN` errors are 774 returned. The `detail` field of the error response will have a `digest` field 775 identifying the missing blob. An error is returned for each unknown blob. The 776 response format is as follows: 777 778 { 779 "errors:" [{ 780 "code": "BLOB_UNKNOWN", 781 "message": "blob unknown to registry", 782 "detail": { 783 "digest": <digest> 784 } 785 }, 786 ... 787 ] 788 } 789 790 ### Listing Repositories 791 792 Images are stored in collections, known as a _repository_, which is keyed by a 793 `name`, as seen throughout the API specification. A registry instance may 794 contain several repositories. The list of available repositories is made 795 available through the _catalog_. 796 797 The catalog for a given registry can be retrieved with the following request: 798 799 ``` 800 GET /v2/_catalog 801 ``` 802 803 The response will be in the following format: 804 805 ``` 806 200 OK 807 Content-Type: application/json 808 809 { 810 "repositories": [ 811 <name>, 812 ... 813 ] 814 } 815 ``` 816 817 Note that the contents of the response are specific to the registry 818 implementation. Some registries may opt to provide a full catalog output, 819 limit it based on the user's access level or omit upstream results, if 820 providing mirroring functionality. Subsequently, the presence of a repository 821 in the catalog listing only means that the registry *may* provide access to 822 the repository at the time of the request. Conversely, a missing entry does 823 *not* mean that the registry does not have the repository. More succinctly, 824 the presence of a repository only guarantees that it is there but not that it 825 is _not_ there. 826 827 For registries with a large number of repositories, this response may be quite 828 large. If such a response is expected, one should use pagination. A registry 829 may also limit the amount of responses returned even if pagination was not 830 explicitly requested. In this case the `Link` header will be returned along 831 with the results, and subsequent results can be obtained by following the link 832 as if pagination had been initially requested. 833 834 For details of the `Link` header, please see the _Pagination_ section. 835 836 #### Pagination 837 838 Paginated catalog results can be retrieved by adding an `n` parameter to the 839 request URL, declaring that the response should be limited to `n` results. 840 Starting a paginated flow begins as follows: 841 842 ``` 843 GET /v2/_catalog?n=<integer> 844 ``` 845 846 The above specifies that a catalog response should be returned, from the start of 847 the result set, ordered lexically, limiting the number of results to `n`. The 848 response to such a request would look as follows: 849 850 ``` 851 200 OK 852 Content-Type: application/json 853 Link: <<url>?n=<n from the request>&last=<last repository in response>>; rel="next" 854 855 { 856 "repositories": [ 857 <name>, 858 ... 859 ] 860 } 861 ``` 862 863 The above includes the _first_ `n` entries from the result set. To get the 864 _next_ `n` entries, one can create a URL where the argument `last` has the 865 value from `repositories[len(repositories)-1]`. If there are indeed more 866 results, the URL for the next block is encoded in an 867 [RFC5988](https://tools.ietf.org/html/rfc5988) `Link` header, as a "next" 868 relation. The presence of the `Link` header communicates to the client that 869 the entire result set has not been returned and another request must be 870 issued. If the header is not present, the client can assume that all results 871 have been recieved. 872 873 > __NOTE:__ In the request template above, note that the brackets 874 > are required. For example, if the url is 875 > `http://example.com/v2/_catalog?n=20&last=b`, the value of the header would 876 > be `<http://example.com/v2/_catalog?n=20&last=b>; rel="next"`. Please see 877 > [RFC5988](https://tools.ietf.org/html/rfc5988) for details. 878 879 Compliant client implementations should always use the `Link` header 880 value when proceeding through results linearly. The client may construct URLs 881 to skip forward in the catalog. 882 883 To get the next result set, a client would issue the request as follows, using 884 the URL encoded in the described `Link` header: 885 886 ``` 887 GET /v2/_catalog?n=<n from the request>&last=<last repository value from previous response> 888 ``` 889 890 The above process should then be repeated until the `Link` header is no longer 891 set. 892 893 The catalog result set is represented abstractly as a lexically sorted list, 894 where the position in that list can be specified by the query term `last`. The 895 entries in the response start _after_ the term specified by `last`, up to `n` 896 entries. 897 898 The behavior of `last` is quite simple when demonstrated with an example. Let 899 us say the registry has the following repositories: 900 901 ``` 902 a 903 b 904 c 905 d 906 ``` 907 908 If the value of `n` is 2, _a_ and _b_ will be returned on the first response. 909 The `Link` header returned on the response will have `n` set to 2 and last set 910 to _b_: 911 912 ``` 913 Link: <<url>?n=2&last=b>; rel="next" 914 ``` 915 916 The client can then issue the request with above value from the `Link` header, 917 receiving the values _c_ and _d_. Note that n may change on second to last 918 response or be omitted fully, if the server may so choose. 919 920 ### Listing Image Tags 921 922 It may be necessary to list all of the tags under a given repository. The tags 923 for an image repository can be retrieved with the following request: 924 925 GET /v2/<name>/tags/list 926 927 The response will be in the following format: 928 929 200 OK 930 Content-Type: application/json 931 932 { 933 "name": <name>, 934 "tags": [ 935 <tag>, 936 ... 937 ] 938 } 939 940 For repositories with a large number of tags, this response may be quite 941 large. If such a response is expected, one should use the pagination. 942 943 #### Pagination 944 945 Paginated tag results can be retrieved by adding the appropriate parameters to 946 the request URL described above. The behavior of tag pagination is identical 947 to that specified for catalog pagination. We cover a simple flow to highlight 948 any differences. 949 950 Starting a paginated flow may begin as follows: 951 952 ``` 953 GET /v2/<name>/tags/list?n=<integer> 954 ``` 955 956 The above specifies that a tags response should be returned, from the start of 957 the result set, ordered lexically, limiting the number of results to `n`. The 958 response to such a request would look as follows: 959 960 ``` 961 200 OK 962 Content-Type: application/json 963 Link: <<url>?n=<n from the request>&last=<last tag value from previous response>>; rel="next" 964 965 { 966 "name": <name>, 967 "tags": [ 968 <tag>, 969 ... 970 ] 971 } 972 ``` 973 974 To get the next result set, a client would issue the request as follows, using 975 the value encoded in the [RFC5988](https://tools.ietf.org/html/rfc5988) `Link` 976 header: 977 978 ``` 979 GET /v2/<name>/tags/list?n=<n from the request>&last=<last tag value from previous response> 980 ``` 981 982 The above process should then be repeated until the `Link` header is no longer 983 set in the response. The behavior of the `last` parameter, the provided 984 response result, lexical ordering and encoding of the `Link` header are 985 identical to that of catalog pagination. 986 987 ### Deleting an Image 988 989 An image may be deleted from the registry via its `name` and `reference`. A 990 delete may be issued with the following request format: 991 992 DELETE /v2/<name>/manifests/<reference> 993 994 For deletes, `reference` *must* be a digest or the delete will fail. If the 995 image exists and has been successfully deleted, the following response will be 996 issued: 997 998 202 Accepted 999 Content-Length: None 1000 1001 If the image had already been deleted or did not exist, a `404 Not Found` 1002 response will be issued instead. 1003 1004 ## Detail 1005 1006 > **Note**: This section is still under construction. For the purposes of 1007 > implementation, if any details below differ from the described request flows 1008 > above, the section below should be corrected. When they match, this note 1009 > should be removed. 1010 1011 The behavior of the endpoints are covered in detail in this section, organized 1012 by route and entity. All aspects of the request and responses are covered, 1013 including headers, parameters and body formats. Examples of requests and their 1014 corresponding responses, with success and failure, are enumerated. 1015 1016 > **Note**: The sections on endpoint detail are arranged with an example 1017 > request, a description of the request, followed by information about that 1018 > request. 1019 1020 A list of methods and URIs are covered in the table below: 1021 1022 |Method|Path|Entity|Description| 1023 |------|----|------|-----------| 1024 {{range $route := .RouteDescriptors}}{{range $method := .Methods}}| {{$method.Method}} | `{{$route.Path|prettygorilla}}` | {{$route.Entity}} | {{$method.Description}} | 1025 {{end}}{{end}} 1026 1027 The detail for each endpoint is covered in the following sections. 1028 1029 ### Errors 1030 1031 The error codes encountered via the API are enumerated in the following table: 1032 1033 |Code|Message|Description| 1034 |----|-------|-----------| 1035 {{range $err := .ErrorDescriptors}} `{{$err.Value}}` | {{$err.Message}} | {{$err.Description|removenewlines}} 1036 {{end}} 1037 1038 {{range $route := .RouteDescriptors}} 1039 ### {{.Entity}} 1040 1041 {{.Description}} 1042 1043 {{range $method := $route.Methods}} 1044 1045 #### {{.Method}} {{$route.Entity}} 1046 1047 {{.Description}} 1048 1049 {{if .Requests}}{{range .Requests}}{{if .Name}} 1050 ##### {{.Name}}{{end}} 1051 1052 ``` 1053 {{$method.Method}} {{$route.Path|prettygorilla}}{{range $i, $param := .QueryParameters}}{{if eq $i 0}}?{{else}}&{{end}}{{$param.Name}}={{$param.Format}}{{end}}{{range .Headers}} 1054 {{.Name}}: {{.Format}}{{end}}{{if .Body.ContentType}} 1055 Content-Type: {{.Body.ContentType}}{{end}}{{if .Body.Format}} 1056 1057 {{.Body.Format}}{{end}} 1058 ``` 1059 1060 {{.Description}} 1061 1062 {{if or .Headers .PathParameters .QueryParameters}} 1063 The following parameters should be specified on the request: 1064 1065 |Name|Kind|Description| 1066 |----|----|-----------| 1067 {{range .Headers}}|`{{.Name}}`|header|{{.Description}}| 1068 {{end}}{{range .PathParameters}}|`{{.Name}}`|path|{{.Description}}| 1069 {{end}}{{range .QueryParameters}}|`{{.Name}}`|query|{{.Description}}| 1070 {{end}}{{end}} 1071 1072 {{if .Successes}} 1073 {{range .Successes}} 1074 ###### On Success: {{if .Name}}{{.Name}}{{else}}{{.StatusCode | statustext}}{{end}} 1075 1076 ``` 1077 {{.StatusCode}} {{.StatusCode | statustext}}{{range .Headers}} 1078 {{.Name}}: {{.Format}}{{end}}{{if .Body.ContentType}} 1079 Content-Type: {{.Body.ContentType}}{{end}}{{if .Body.Format}} 1080 1081 {{.Body.Format}}{{end}} 1082 ``` 1083 1084 {{.Description}} 1085 {{if .Fields}}The following fields may be returned in the response body: 1086 1087 |Name|Description| 1088 |----|-----------| 1089 {{range .Fields}}|`{{.Name}}`|{{.Description}}| 1090 {{end}}{{end}}{{if .Headers}} 1091 The following headers will be returned with the response: 1092 1093 |Name|Description| 1094 |----|-----------| 1095 {{range .Headers}}|`{{.Name}}`|{{.Description}}| 1096 {{end}}{{end}}{{end}}{{end}} 1097 1098 {{if .Failures}} 1099 {{range .Failures}} 1100 ###### On Failure: {{if .Name}}{{.Name}}{{else}}{{.StatusCode | statustext}}{{end}} 1101 1102 ``` 1103 {{.StatusCode}} {{.StatusCode | statustext}}{{range .Headers}} 1104 {{.Name}}: {{.Format}}{{end}}{{if .Body.ContentType}} 1105 Content-Type: {{.Body.ContentType}}{{end}}{{if .Body.Format}} 1106 1107 {{.Body.Format}}{{end}} 1108 ``` 1109 1110 {{.Description}} 1111 {{if .Headers}} 1112 The following headers will be returned on the response: 1113 1114 |Name|Description| 1115 |----|-----------| 1116 {{range .Headers}}|`{{.Name}}`|{{.Description}}| 1117 {{end}}{{end}} 1118 1119 {{if .ErrorCodes}} 1120 The error codes that may be included in the response body are enumerated below: 1121 1122 |Code|Message|Description| 1123 |----|-------|-----------| 1124 {{range $err := .ErrorCodes}}| `{{$err}}` | {{$err.Descriptor.Message}} | {{$err.Descriptor.Description|removenewlines}} | 1125 {{end}} 1126 1127 {{end}}{{end}}{{end}}{{end}}{{end}}{{end}} 1128 1129 {{end}}