If you do not require a large number of namespaces, private repositories, and build rules, we recommend that you use Container Registry Personal Edition that provides basic image features. This topic describes how to create a repository, configure build rules, and build images in the Container Registry Personal Edition instance.

Features

  • Container Registry can automatically build images when code changes.

    After you turn on Automatically Build Images When Code Changes, an image is automatically built each time you commit the code. This reduces the manual workload.

    1. Log on to the Container Registry console.
    2. In the top navigation bar, select a region.
    3. In the left-side navigation pane, click Instances.
    4. On the Instances page, click the default instance.
    5. On the management page of the Container Registry Personal Edition instance, choose Repositories > Repositories in the left-side navigation pane.
    6. On the Repositories page, find the repository that you want to manage and click Manage in the Actions column.
    7. In the left-side navigation pane, click Build. On the page that appears, turn on Automatically Build Images When Code Changes.
    Automatically Build Images When Code Changes
  • Container Registry can build images on servers outside mainland China.
    The source code used for building images may be stored in a source code repository outside mainland China. You may have no access to such a repository over the network. To resolve this issue, Container Registry provides the Build With Servers Deployed Outside Mainland China feature. After an image is built on a server outside mainland China, the image is pushed to a repository in the specified region.
    Note Image pushes may time out if the network from outside mainland China to mainland China is unstable.
  • Container Registry can build images without using the cache.

    After you turn on Build Without Cache, the dependent base image is pulled each time you build an image. This may slow down the build process. We recommend that you turn off the switch.

  • Container Registry supports multi-stage builds.

Create an image repository

Before you create an image repository, make sure that a namespace is created in the specified region. For more information, see Manage namespaces.

  1. Log on to the Container Registry console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Instances.
  4. On the Instances page, click the default instance.
  5. On the management page of the Container Registry Personal Edition instance, choose Repositories > Repositories in the left-side navigation pane.
  6. On the Repositories page, click Create Repository.
  7. In the Create Repository dialog box, set the namespace, repository name, repository type, and summary. In this example, set the repository type to Private. Then, click Next.
  8. In the Code Source step, set the Code Source parameter to Code and click Create Repository.
    • Automatically Build Images When Code Changes: If you select this option, an image is automatically built when code is committed from a branch.
    • Build With Servers Deployed Outside Mainland China: If you select this option, images are built in a data center outside mainland China and then pushed to the image repository.
    • Build Without Cache: If you select this option, the system pulls the dependent base image for every image to be built. This may slow down the build process.

Configure build rules

  1. Log on to the Container Registry console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Instances.
  4. On the Instances page, click the default instance.
  5. On the management page of the Container Registry Personal Edition instance, choose Repositories > Repositories in the left-side navigation pane.
  6. On the Repositories page, find the created image repository and click Manage in the Actions column.
  7. In the left-side navigation pane, click Build. On the page that appears, click Add Build Rule in the Build Rules section.
    Note To modify a build rule, click Modify in the Actions column of the build rule.
  8. In the Add Build Rule dialog box, configure the build rule and click Confirm.
    • Type: the type for the source code repository. Valid values: Branch and Tag.
    • Code Branch/Tag: the code branch for building images.
    • Dockerfile Directory: the directory where the Dockerfile resides. The specified directory is a relative directory, with the root directory of the code branch as its parent directory.
    • Dockerfile Filename: the name of the Dockerfile. Default value: Dockerfile.
    • Tags: the tag of the image, for example, latest.

Build images

  1. Log on to the Container Registry console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Instances.
  4. On the Instances page, click the default instance.
  5. On the management page of the Container Registry Personal Edition instance, choose Repositories > Repositories in the left-side navigation pane.
  6. On the Repositories page, find the repository that you want to manage and click Manage in the Actions column.
  7. Go to the repository details page. In the left-side navigation pane, click Build.
  8. In the Build Rules section, click Build in the Actions column of a build rule. Build

    After the image is built, a build record is generated.

  9. Click Log in the Actions column of the build record to view the log details.
  10. After the image is built, click Tags in the left-side navigation pane to view the list of created images.

  11. To view all the images, click Build in the left-side navigation pane. On the page that appears, turn on Build With Servers Deployed Outside Mainland China and Build Without Cache and retain the default setting for Automatically Build Images When Code Changes in the Build Settings section. Then, you can view all the tags. Tags

What to do next