Docker Getting Started Tutorial (7) Docker API

[Editor's Note] DockerOne organization translated Flux7's Docker introductory tutorial, this article is the seventh series of introductory tutorial, focusing on the Docker Registry API and Docker Hub API.

Looking at our Docker series of tutorials, we have discussed a lot of important Docker components and commands . In this article, we will continue to dig deeper into Docker: Analyze Docker APIs.

Docker provides a lot of APIs for use by users. These APIs contain four aspects:

  • Docker Registry API
  • Docker Hub API
  • Docker OAuth API
  • Docker Remote API

Specific to this article, we will discuss the Docker Registry API and the Docker Hub API.

Docker Registry API

The Docker Registry API is the REST API of the Docker Registry , which simplifies storage of mirroring and warehousing. The API can not access the user account or be authorized. You can read the fourth chapter of the Docker series tutorials to learn more about the types of registries. There are several different registries in Docker.

Extract image layer:

Remove the mirror layer:
GET /v1/images/(image_id)/layer

Insert image layer:

Insert image layer:
PUT /v1/images/(image_id)/layer

Retrieve an image:

Retrieve Mirror:
GET /v1/images/(image_id)/json

Retrieve roots of an image:

Retrieve the root image:
GET /v1/images/(image_id)/ancestry

Obtain all tags or specific tag of a repository:

Get all the labels or labels in the library:
GET /v1/repositories/(namespace)/(repository)/tags

GET /v1/repositories/(namespace)/(repository)/tags/(tag*)

Delete a tag:

Remove label:
DELETE /v1/repositories/(namespace)/(repository)/tags/(tag*)

Status check of registry:

Registry status check:
GET /v1/_ping

Docker Hub API

The Docker Hub API is a simple REST API for the Docker Hub. Please remind us about the Docker series in the fourth article of the Docker series . The Docker Hub controls user accounts and authorizations by managing checksums and public namespaces. The API also supports operations on the user repository and the library repository.

First, let's take a look at the special library repository (which requires administrator privileges)
1. Create a new repository . Use the following command to create a new library repository:
PUT /v1/repositories/(repo_name)/
Where repo_name is the new repository name.
2. Delete the existing repository . The order is as follows:
DELETE /v1/repositories/(repo_name)/
Where repo_name is the name of the repository to be deleted.
3. Update the warehouse image . The order is as follows:
PUT /v1/repositories/(repo_name)/images
4. Obtain a mirror from the warehouse . The order is as follows:
GET /v1/repositories/(repo_name)/images
5. Authorization . Use Token to get the repository authorization as follows:
PUT /v1/repositories/(repo_name)/auth
Next, let's take a look at the user repository command. The main difference between the library repository and the user repository command is the use of the namespace.

1. Create a user repository . The order is as follows:
PUT /v1/repositories/(namespace)/(repo_name)/
2. Delete the user repository , the command is as follows:
DELETE /v1/repositories/(namespace)/(repo_name)/
3. Update the user repository image , as follows:
PUT /v1/repositories/(namespace)/(repo_name)/images
4. Download the image from the warehouse . as follows:
GET /v1/repositories/(namespace)/(repo_name)/images
5. Verify that the user is logged in as follows:
GET /v1/users
6. Add a new user , the command is as follows:
POST /v1/users
7. Update the user information as follows:
PUT /v1/users/(username)/

Now that we've gone through the first stop of the Docker API tour, the second stop is about Docker OAuth and the contents of the Remote API, which we'll see in the next article in the Docker series .

Source: Ultimate Guide for Docker APIs (Translated by: Tian Haohao Reviser: Li Yingjie)

Translator introduction
Tian Haohao , University of Sydney USYD graduate, currently engaged in the development of Android in Zhuhai work. Spare time to focus on Docker's study and research, hoping to DockerOne to the latest and best translation of the contribution to everyone, with the reader to swim Docker's ocean.

Docker Getting Started Tutorial (1) Introduction
Docker Getting Started Tutorial (2) Order
Docker Getting Started Tutorial (3) DockerFile
Docker Getting Started Tutorial (4) Docker Registry
Docker Getting Started Tutorial (5) Docker Security
Docker Getting Started Tutorial (6) Additional 15 Docker commands
Docker Getting Started Tutorial (7) Docker API
Docker Getting Started Tutorial (8) Docker Remote API
Docker Getting Started Tutorial (9) 10 mirror related APIs

    Heads up! This alert needs your attention, but it's not super important.