Docker tutorial on Docker Hub

  • 2020-05-30 21:42:31
  • OfStack

Docker Hub

The repository (Repository) is where the mirrors are centralized.

One confusing concept is the registration server (Registry). In fact, the registration server is the concrete server that manages the warehouse, and there can be multiple warehouses on each server, and multiple images under each warehouse. In this sense, a warehouse can be thought of as a specific item or directory. For example, the warehouse address dl. dockerpool. com/ubuntu, dl. dockerpool. com is a registered server address, ubuntu is warehouse.

Most of the time, it is not necessary to strictly distinguish between the two concepts.

Currently, Docker maintains a public warehouse, Docker Hub, which already contains over 15,000 mirrors. Most of the requirements can be achieved by downloading the image directly from Docker Hub.

The login

You can complete registration and login by executing the docker login command to enter a user name, password, and mailbox. Upon successful registration, the user's authentication information is saved in the.dockercfg of the local user directory.

Basic operation

Users do not need to log in to find the image in the official repository through the docker search command and download it locally using the docker pull command.

For example, search with centos as the keyword:


$ sudo docker search centos
NAME                      DESCRIPTION                   STARS   OFFICIAL  AUTOMATED
centos                     The official build of CentOS.          465    [OK]
tianon/centos                  CentOS 5 and 6, created using rinse instea...  28
blalor/centos                  Bare-bones base CentOS 6.5 image        6          [OK]
saltstack/centos-6-minimal                                   6          [OK]
tutum/centos-6.4                DEPRECATED. Use tutum/centos:6.4 instead. ...  5          [OK]
...

You can see that a number of images containing keywords are returned, including the image name, description, star (indicating the popularity of the image), whether it was officially created, and whether it was created automatically. The official image specification is created and maintained by the official project team, and the automated resource allows users to verify the source and content of the image.

Mirror resources can be divided into two categories, depending on whether they are officially provided or not. One is a base mirror like centos, called a base or root mirror. These base images are created, validated, supported, and provided by Docker. Such mirror images often use a single word as a name. There is also a type, such as tianon/centos mirroring, which is created and maintained by Docker users, often with a user name prefix. You can specify the use of a user-provided image by the prefix user_name/, such as tianon user.

In addition, the -s N parameter can be used to specify that only images evaluated as N stars or above will be displayed when searching.

Download the official centos image locally.


$ sudo docker pull centos
Pulling repository centos
0b443ba03958: Download complete
539c0211cd76: Download complete
511136ea3c5a: Download complete
7064731afe90: Download complete

Users can also push the image to Docker Hub via the docker push command after logging in.

Automatically created

The automatic creation (Automated Builds) feature is 10 points convenient for applications that require frequent updates to the mirror. Sometimes a user creates an image, installs a piece of software, and needs to manually update the image if a new version of the software is released.

Automatic creation allows the user to track an item on a target site (currently supported on GitHub or BitBucket) through Docker Hub, and when a new item is submitted, the creation is automatically performed.

To configure automatic creation, include the following steps:

Create and log in Docker Hub, as well as the target website; Connect accounts to Docker Hub in the target website; Configure 1 automatic creation in Docker Hub; Select a target site in the project (need to include Dockerfile) and branch; Specify the location of Dockerfile and commit to create.

After that, you can track the state of each creation in Docker Hub's automatic creation page.

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: