Container Registry Personal Edition provides basic image features, such as secure management for application images and image scanning that precisely detects vulnerabilities. This topic describes how to use a Container Registry Personal Edition instance to push and pull images.

Prerequisites

Docker is installed. For more information, see Install Docker.

Step 1: Obtain the logon name of the image registry

  • If you use an Alibaba Cloud account, the Alibaba Cloud account is the logon name of the image registry.
  • If you use a RAM user, the string before onaliyun.com is the logon name of the image registry. For example, if your RAM user is 123@1880770869021234.onaliyun.com, the logon name of the image registry is 123@1880770869021234.

Step 2: Set a logon password for the image registry

If you log on to the Container Registry console for the first time, you must set a logon password for the image registry. You must use this password to log on to an image repository before you can push and pull images.

  1. Log on to the Container Registry console.
  2. Click Reset Docker Login Password.
    Note If you forget the logon password for the image registry, you can use an access credential to log on to image repositories. For more information, see Configure an access credential.
  3. In the Reset Docker Login Password dialog box, set the Password and Confirm Password parameters and click Confirm.

Step 3: Create a namespace

You can manage a collection of repositories in a namespace. For example, you can manage permissions on repositories and modify repository attributes by using a namespace.

  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 > Namespaces in the left-side navigation pane.
  6. On the Namespaces page, click Create Namespace.
  7. In the Create Namespace dialog box, enter a namespace name and click Confirm.

Step 4: Create an image repository

  1. Log on to the Container Registry console.
  2. In the left-side navigation pane, click Instances.
  3. On the Instances page, click the default instance.
  4. On the management page of the Container Registry Personal Edition instance, choose Repositories > Repositories in the left-side navigation pane.
  5. On the Repositories page, click Create Repository.
  6. In the Repository Info step, set the Region, Namespaces, Repository Name, Repository Type, Summary, and Description parameters, and click Next.
  7. In the Code Source step, set the Code Source, Build Settings, and Build Rules parameters, and click Create Repository.
    Parameter Description
    Code Source The code source.
    Build Settings
    • 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 prolong the build time.
    Build Rules After the repository is created, you can go to the Build page to create build rules. For more information, see Create a repository and build images.

Step 5: Push and pull an image

  1. Run the following command to log on to the image repository:
    sudo docker login --username=<Registry logon name> registry.cn-<The region where the Container Registry Personal Edition instance resides>.aliyuncs.com

    At the command prompt, enter the logon password that is specified in Step 2: Set a logon password for the image registry. If login succeeded is displayed, the logon is successful.

  2. Push an image.
    1. Run the following command to tag the image:
      sudo docker tag <ImageId> registry.cn-hangzhou.aliyuncs.com/devopes-***/m**:[Image tag]
      • ImageId: the ID of the image.
      • registry.cn-hangzhou.aliyuncs.com/devopes-***/m**: the address of the image repository.
    2. Run the following command to push the image to the Container Registry Personal Edition instance:
      sudo docker push registry.cn-hangzhou.aliyuncs.com/devopes-***/m**:[Image tag]
      On the Repositories page, click the name of the image repository. On the page that appears, click Tags in the left-side navigation pane. If the image appears on the Tags page, the image is pushed to the image repository.
  3. Run the following command to pull an image:
    sudo docker pull registry.cn-hangzhou.aliyuncs.com/devopes-***/m**:[Image tag]
    Run the docker images command. If the image appears in the command output, the image is pulled from the image repository.