github.com/SophiaGitHub/hello@v1.7.1-rc3/docs/reference/api/registry_api.md (about) 1 <!--[metadata]> 2 +++ 3 draft = true 4 title = "Registry v1 API" 5 description = "API Documentation for Docker Registry" 6 keywords = ["API, Docker, index, registry, REST, documentation"] 7 [menu.main] 8 parent="smn_registry_ref" 9 +++ 10 <![end-metadata]--> 11 12 # Docker Registry API v1 13 14 ## Introduction 15 16 - This is the REST API for the Docker Registry 1.0 17 - It stores the images and the graph for a set of repositories 18 - It does not have user accounts data 19 - It has no notion of user accounts or authorization 20 - It delegates authentication and authorization to the Index Auth 21 service using tokens 22 - It supports different storage backends (S3, cloud files, local FS) 23 - It doesn't have a local database 24 - The registry is open source: [Docker Registry](https://github.com/docker/docker-registry) 25 26 We expect that there will be multiple registries out there. To help to 27 grasp the context, here are some examples of registries: 28 29 - **sponsor registry**: such a registry is provided by a third-party 30 hosting infrastructure as a convenience for their customers and the 31 Docker community as a whole. Its costs are supported by the third 32 party, but the management and operation of the registry are 33 supported by Docker. It features read/write access, and delegates 34 authentication and authorization to the Index. 35 - **mirror registry**: such a registry is provided by a third-party 36 hosting infrastructure but is targeted at their customers only. Some 37 mechanism (unspecified to date) ensures that public images are 38 pulled from a sponsor registry to the mirror registry, to make sure 39 that the customers of the third-party provider can `docker pull` 40 those images locally. 41 - **vendor registry**: such a registry is provided by a software 42 vendor, who wants to distribute Docker images. It would be operated 43 and managed by the vendor. Only users authorized by the vendor would 44 be able to get write access. Some images would be public (accessible 45 for anyone), others private (accessible only for authorized users). 46 Authentication and authorization would be delegated to the Index. 47 The goal of vendor registries is to let someone do `docker pull 48 basho/riak1.3` and automatically push from the vendor registry 49 (instead of a sponsor registry); i.e., get all the convenience of a 50 sponsor registry, while retaining control on the asset distribution. 51 - **private registry**: such a registry is located behind a firewall, 52 or protected by an additional security layer (HTTP authorization, 53 SSL client-side certificates, IP address authorization...). The 54 registry is operated by a private entity, outside of Docker's 55 control. It can optionally delegate additional authorization to the 56 Index, but it is not mandatory. 57 58 > **Note**: 59 > Mirror registries and private registries which do not use the Index 60 > don't even need to run the registry code. They can be implemented by any 61 > kind of transport implementing HTTP GET and PUT. Read-only registries 62 > can be powered by a simple static HTTPS server. 63 64 > **Note**: 65 > The latter implies that while HTTP is the protocol of choice for a registry, 66 > multiple schemes are possible (and in some cases, trivial): 67 > 68 > - HTTP with GET (and PUT for read-write registries); 69 > - local mount point; 70 > - remote Docker addressed through SSH. 71 72 The latter would only require two new commands in Docker, e.g., 73 `registryget` and `registryput`, wrapping access to the local filesystem 74 (and optionally doing consistency checks). Authentication and authorization 75 are then delegated to SSH (e.g., with public keys). 76 77 > **Note**: 78 > Private registry servers that expose an HTTP endpoint need to be secured with 79 > TLS (preferably TLSv1.2, but at least TLSv1.0). Make sure to put the CA 80 > certificate at /etc/docker/certs.d/my.registry.com:5000/ca.crt on the Docker 81 > host, so that the daemon can securely access the private registry. 82 > Support for SSLv3 and lower is not available due to security issues. 83 84 The default namespace for a private repository is `library`. 85 86 # Endpoints 87 88 ## Images 89 90 ### Get image layer 91 92 `GET /v1/images/(image_id)/layer` 93 94 Get image layer for a given `image_id` 95 96 **Example Request**: 97 98 GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1 99 Host: registry-1.docker.io 100 Accept: application/json 101 Content-Type: application/json 102 Authorization: Token signature=123abc,repository="foo/bar",access=read 103 104 Parameters: 105 106 - **image_id** – the id for the layer you want to get 107 108 **Example Response**: 109 110 HTTP/1.1 200 111 Vary: Accept 112 X-Docker-Registry-Version: 0.6.0 113 Cookie: (Cookie provided by the Registry) 114 115 {layer binary data stream} 116 117 Status Codes: 118 119 - **200** – OK 120 - **401** – Requires authorization 121 - **404** – Image not found 122 123 ### Put image layer 124 125 `PUT /v1/images/(image_id)/layer` 126 127 Put image layer for a given `image_id` 128 129 **Example Request**: 130 131 PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1 132 Host: registry-1.docker.io 133 Transfer-Encoding: chunked 134 Authorization: Token signature=123abc,repository="foo/bar",access=write 135 136 {layer binary data stream} 137 138 Parameters: 139 140 - **image_id** – the id for the layer you want to get 141 142 **Example Response**: 143 144 HTTP/1.1 200 145 Vary: Accept 146 Content-Type: application/json 147 X-Docker-Registry-Version: 0.6.0 148 149 "" 150 151 Status Codes: 152 153 - **200** – OK 154 - **401** – Requires authorization 155 - **404** – Image not found 156 157 ## Image 158 159 ### Put image layer 160 161 `PUT /v1/images/(image_id)/json` 162 163 Put image for a given `image_id` 164 165 **Example Request**: 166 167 PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1 168 Host: registry-1.docker.io 169 Accept: application/json 170 Content-Type: application/json 171 Cookie: (Cookie provided by the Registry) 172 173 { 174 id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c", 175 parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f", 176 created: "2013-04-30T17:46:10.843673+03:00", 177 container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7", 178 container_config: { 179 Hostname: "host-test", 180 User: "", 181 Memory: 0, 182 MemorySwap: 0, 183 AttachStdin: false, 184 AttachStdout: false, 185 AttachStderr: false, 186 PortSpecs: null, 187 Tty: false, 188 OpenStdin: false, 189 StdinOnce: false, 190 Env: null, 191 Cmd: [ 192 "/bin/bash", 193 "-c", 194 "apt-get -q -yy -f install libevent-dev" 195 ], 196 Dns: null, 197 Image: "imagename/blah", 198 Volumes: { }, 199 VolumesFrom: "" 200 }, 201 docker_version: "0.1.7" 202 } 203 204 Parameters: 205 206 - **image_id** – the id for the layer you want to get 207 208 **Example Response**: 209 210 HTTP/1.1 200 211 Vary: Accept 212 Content-Type: application/json 213 X-Docker-Registry-Version: 0.6.0 214 215 "" 216 217 Status Codes: 218 219 - **200** – OK 220 - **401** – Requires authorization 221 222 ### Get image layer 223 224 `GET /v1/images/(image_id)/json` 225 226 Get image for a given `image_id` 227 228 **Example Request**: 229 230 GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1 231 Host: registry-1.docker.io 232 Accept: application/json 233 Content-Type: application/json 234 Cookie: (Cookie provided by the Registry) 235 236 Parameters: 237 238 - **image_id** – the id for the layer you want to get 239 240 **Example Response**: 241 242 HTTP/1.1 200 243 Vary: Accept 244 Content-Type: application/json 245 X-Docker-Registry-Version: 0.6.0 246 X-Docker-Size: 456789 247 X-Docker-Checksum: b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087 248 249 { 250 id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c", 251 parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f", 252 created: "2013-04-30T17:46:10.843673+03:00", 253 container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7", 254 container_config: { 255 Hostname: "host-test", 256 User: "", 257 Memory: 0, 258 MemorySwap: 0, 259 AttachStdin: false, 260 AttachStdout: false, 261 AttachStderr: false, 262 PortSpecs: null, 263 Tty: false, 264 OpenStdin: false, 265 StdinOnce: false, 266 Env: null, 267 Cmd: [ 268 "/bin/bash", 269 "-c", 270 "apt-get -q -yy -f install libevent-dev" 271 ], 272 Dns: null, 273 Image: "imagename/blah", 274 Volumes: { }, 275 VolumesFrom: "" 276 }, 277 docker_version: "0.1.7" 278 } 279 280 Status Codes: 281 282 - **200** – OK 283 - **401** – Requires authorization 284 - **404** – Image not found 285 286 ## Ancestry 287 288 ### Get image ancestry 289 290 `GET /v1/images/(image_id)/ancestry` 291 292 Get ancestry for an image given an `image_id` 293 294 **Example Request**: 295 296 GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/ancestry HTTP/1.1 297 Host: registry-1.docker.io 298 Accept: application/json 299 Content-Type: application/json 300 Cookie: (Cookie provided by the Registry) 301 302 Parameters: 303 304 - **image_id** – the id for the layer you want to get 305 306 **Example Response**: 307 308 HTTP/1.1 200 309 Vary: Accept 310 Content-Type: application/json 311 X-Docker-Registry-Version: 0.6.0 312 313 ["088b4502f51920fbd9b7c503e87c7a2c05aa3adc3d35e79c031fa126b403200f", 314 "aeee63968d87c7da4a5cf5d2be6bee4e21bc226fd62273d180a49c96c62e4543", 315 "bfa4c5326bc764280b0863b46a4b20d940bc1897ef9c1dfec060604bdc383280", 316 "6ab5893c6927c15a15665191f2c6cf751f5056d8b95ceee32e43c5e8a3648544"] 317 318 Status Codes: 319 320 - **200** – OK 321 - **401** – Requires authorization 322 - **404** – Image not found 323 324 ## Tags 325 326 ### List repository tags 327 328 `GET /v1/repositories/(namespace)/(repository)/tags` 329 330 Get all of the tags for the given repo. 331 332 **Example Request**: 333 334 GET /v1/repositories/reynholm/help-system-server/tags HTTP/1.1 335 Host: registry-1.docker.io 336 Accept: application/json 337 Content-Type: application/json 338 X-Docker-Registry-Version: 0.6.0 339 Cookie: (Cookie provided by the Registry) 340 341 Parameters: 342 343 - **namespace** – namespace for the repo 344 - **repository** – name for the repo 345 346 **Example Response**: 347 348 HTTP/1.1 200 349 Vary: Accept 350 Content-Type: application/json 351 X-Docker-Registry-Version: 0.6.0 352 353 { 354 "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f", 355 "0.1.1": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087" 356 } 357 358 Status Codes: 359 360 - **200** – OK 361 - **401** – Requires authorization 362 - **404** – Repository not found 363 364 ### Get image id for a particular tag 365 366 `GET /v1/repositories/(namespace)/(repository)/tags/(tag*)` 367 368 Get a tag for the given repo. 369 370 **Example Request**: 371 372 GET /v1/repositories/reynholm/help-system-server/tags/latest HTTP/1.1 373 Host: registry-1.docker.io 374 Accept: application/json 375 Content-Type: application/json 376 X-Docker-Registry-Version: 0.6.0 377 Cookie: (Cookie provided by the Registry) 378 379 Parameters: 380 381 - **namespace** – namespace for the repo 382 - **repository** – name for the repo 383 - **tag** – name of tag you want to get 384 385 **Example Response**: 386 387 HTTP/1.1 200 388 Vary: Accept 389 Content-Type: application/json 390 X-Docker-Registry-Version: 0.6.0 391 392 "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f" 393 394 Status Codes: 395 396 - **200** – OK 397 - **401** – Requires authorization 398 - **404** – Tag not found 399 400 ### Delete a repository tag 401 402 `DELETE /v1/repositories/(namespace)/(repository)/tags/(tag*)` 403 404 Delete the tag for the repo 405 406 **Example Request**: 407 408 DELETE /v1/repositories/reynholm/help-system-server/tags/latest HTTP/1.1 409 Host: registry-1.docker.io 410 Accept: application/json 411 Content-Type: application/json 412 Cookie: (Cookie provided by the Registry) 413 414 Parameters: 415 416 - **namespace** – namespace for the repo 417 - **repository** – name for the repo 418 - **tag** – name of tag you want to delete 419 420 **Example Response**: 421 422 HTTP/1.1 200 423 Vary: Accept 424 Content-Type: application/json 425 X-Docker-Registry-Version: 0.6.0 426 427 "" 428 429 Status Codes: 430 431 - **200** – OK 432 - **401** – Requires authorization 433 - **404** – Tag not found 434 435 ### Set a tag for a specified image id 436 437 `PUT /v1/repositories/(namespace)/(repository)/tags/(tag*)` 438 439 Put a tag for the given repo. 440 441 **Example Request**: 442 443 PUT /v1/repositories/reynholm/help-system-server/tags/latest HTTP/1.1 444 Host: registry-1.docker.io 445 Accept: application/json 446 Content-Type: application/json 447 Cookie: (Cookie provided by the Registry) 448 449 "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f" 450 451 Parameters: 452 453 - **namespace** – namespace for the repo 454 - **repository** – name for the repo 455 - **tag** – name of tag you want to add 456 457 **Example Response**: 458 459 HTTP/1.1 200 460 Vary: Accept 461 Content-Type: application/json 462 X-Docker-Registry-Version: 0.6.0 463 464 "" 465 466 Status Codes: 467 468 - **200** – OK 469 - **400** – Invalid data 470 - **401** – Requires authorization 471 - **404** – Image not found 472 473 ## Repositories 474 475 ### Delete a repository 476 477 `DELETE /v1/repositories/(namespace)/(repository)/` 478 479 Delete a repository 480 481 **Example Request**: 482 483 DELETE /v1/repositories/reynholm/help-system-server/ HTTP/1.1 484 Host: registry-1.docker.io 485 Accept: application/json 486 Content-Type: application/json 487 Cookie: (Cookie provided by the Registry) 488 489 "" 490 491 Parameters: 492 493 - **namespace** – namespace for the repo 494 - **repository** – name for the repo 495 496 **Example Response**: 497 498 HTTP/1.1 200 499 Vary: Accept 500 Content-Type: application/json 501 X-Docker-Registry-Version: 0.6.0 502 503 "" 504 505 Status Codes: 506 507 - **200** – OK 508 - **401** – Requires authorization 509 - **404** – Repository not found 510 511 ## Search 512 513 If you need to search the index, this is the endpoint you would use. 514 515 `GET /v1/search` 516 517 Search the Index given a search term. It accepts 518 519 [GET](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3) 520 only. 521 522 **Example request**: 523 524 GET /v1/search?q=search_term&page=1&n=25 HTTP/1.1 525 Host: index.docker.io 526 Accept: application/json 527 528 Query Parameters: 529 530 - **q** – what you want to search for 531 - **n** - number of results you want returned per page (default: 25, min:1, max:100) 532 - **page** - page number of results 533 534 **Example response**: 535 536 HTTP/1.1 200 OK 537 Vary: Accept 538 Content-Type: application/json 539 540 {"num_pages": 1, 541 "num_results": 3, 542 "results" : [ 543 {"name": "ubuntu", "description": "An ubuntu image..."}, 544 {"name": "centos", "description": "A centos image..."}, 545 {"name": "fedora", "description": "A fedora image..."} 546 ], 547 "page_size": 25, 548 "query":"search_term", 549 "page": 1 550 } 551 552 Response Items: 553 - **num_pages** - Total number of pages returned by query 554 - **num_results** - Total number of results returned by query 555 - **results** - List of results for the current page 556 - **page_size** - How many results returned per page 557 - **query** - Your search term 558 - **page** - Current page number 559 560 Status Codes: 561 562 - **200** – no error 563 - **500** – server error 564 565 ## Status 566 567 ### Status check for registry 568 569 `GET /v1/_ping` 570 571 Check status of the registry. This endpoint is also used to 572 determine if the registry supports SSL. 573 574 **Example Request**: 575 576 GET /v1/_ping HTTP/1.1 577 Host: registry-1.docker.io 578 Accept: application/json 579 Content-Type: application/json 580 581 "" 582 583 **Example Response**: 584 585 HTTP/1.1 200 586 Vary: Accept 587 Content-Type: application/json 588 X-Docker-Registry-Version: 0.6.0 589 590 "" 591 592 Status Codes: 593 594 - **200** – OK 595 596 ## Authorization 597 598 This is where we describe the authorization process, including the 599 tokens and cookies. 600