Docker Registry has an HTTP interface to interact with Docker Engine. This is used to manage information about Docker images and enable their distribution.
The key update from V1 is the set of changes in the Docker image format and concept of signed manifest. The new, self-contained image manifest simplifies image definition and improves security. This specification will build on that work, leveraging new properties of the manifest format to improve performance, reduce bandwidth usage, and decrease the likelihood of backend corruption.
The complete documentation of the Docker Registry V2 APIs can be found here:
https://github.com/docker/distribution/blob/master/docs/spec/api.md.
The important APIs are discussed here:
- API version check:
Here is the curl command to check the Docker Registry API version:
$ curl -i http://localhost:5000/v2/
HTTP/1.1 200 OK
Content-Length: 2
Content-Type: application/json; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
Date: Mon, 21 Nov 2016 18:37:06 GMT
The supported error codes are 401 Unauthorized and 404 Not Found.
- Listing repositories:
Here is the curl command to get the contents of repository:
$ curl -i http://localhost:5000/v2/_catalog
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
Date: Mon, 21 Nov 2016 18:36:42 GMT
Content-Length: 33
{"repositories":["hello-world"]}
The reader may recall that while starting Docker Registry, we uploaded only one file.
- Pulling an image: The Docker image mainly consists of two parts—a JSON manifest and individual layer files.
Pulling an image manifest can be fetched using the following URL:
GET /v2/<name>/manifests/<reference>
Here is the curl command to get the image manifest details.
curl -i http://localhost:5000/v2/
hello-world/manifests/latestHTTP/1.1 200 OK
Content-Length: 2742
Content-Type: application/vnd.docker.distribution.
manifest.v1+prettyjws
Docker-Content-Digest:
sha256:f18d040ea7bf47c7ea8f7ff1a8682811cf375
51c747158e37b9c75f5450e6fac
Docker-Distribution-Api-Version: registry/2.0
Date: Mon, 21 Nov 2016 18:54:05 GMT
{
"schemaVersion": 1,
"name": "hello-world",
"tag": "latest",
"architecture": "amd64",
"fsLayers": [
{
"blobSum":
"sha256:a3ed95caeb02ffe68cdd9fd8440
6680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum":
"sha256:c04b14da8d1441880ed3fe6106fb2cc
6fa1c9661846ac0266b8a5ec8edf37b7c"
}
],
"history": [
}{
"v1Compatibility": "----
}
],
"signatures":[
{
"----------------"
}
]
}
- Pulling the layers of an image stored in blob:
GET /v2/<name>/blobs/<digest>
This will be an exercise for the reader to download the image using <digest> received in the preceding pulling manifest API.
A list of methods and URIs are covered in the following table:
Method |
Path |
Entity |
Description |
GET |
/v2/ |
Base |
Check that the endpoint implements the Docker Registry API V2 |
GET |
/v2/<name>/tag/list |
Tags |
Fetch the tags under the repository identified by name |
GET |
/v2/<name>/manifests/<reference> |
Manifest |
Fetch the manifest identified by name and reference, where reference can be a tag or digest |
PUT |
/v2/<name>/manifests/<reference> |
Manifest |
Put the manifest identified by name and reference, where reference can be a tag or digest |
Delete |
/v2/<name>/manifests/<reference> |
Manifest |
Delete the manifest identified by name and reference, where reference can be a tag or digest |
GET |
/v2/<name>/blobs/<digest> |
Blob |
Retrieve the blob from the registry identified by a digest |
DELETE |
/v2/<name>/blobs/<digest> |
Blob |
Delete the blob from the registry identified by a digest |
POST |
/v2/<name>/blobs/uploads |
Initiate blob upload |
Initiate a resumable blob upload; if successful, an upload location will be provided to complete the upload |
GET |
/v2/<name>/blobs/uploads/<uuid> |
Blob upload |
Retrieve the status of upload identified by uuid |
PATCH |
/v2/<name>/blobs/uploads/<uuid> |
Blob upload |
Update a chunk of data for the specified upload |
PUT |
/v2/<name>/blobs/uploads/<uuid> |
Blob upload |
Complete the upload specified by uuid |
DELETE |
/v2/<name>/blobs/uploads/<uuid> |
Blob upload |
Cancel outstanding upload processes, releasing associated resources |
GET |
/v2/_catalog |
Catalog |
Retrieve a sorted JSON list of repositories from the registry |