All Products
Search
Document Center

Container Registry:Basic operations on Docker

Last Updated:Feb 26, 2024

This topic describes the three most common operations on Docker, namely, docker login, docker pull, and docker push. This topic also describes how to log on to a Container Registry Enterprise Edition instance. You can better use Container Registry after you get familiar with basic operations on Docker images.

Background information

Before you use Container Registry, you must install Docker. For more information about how to install Docker, see the following topics:

docker login

The following section provides an example on how to log on to a Container Registry Enterprise Edition instance which is located in the China (Hangzhou) region.

  1. Specify the domain name of the Container Registry Enterprise Edition instance and enter your username and logon password.

    After you log on to the Container Registry Enterprise Edition instance, Login Succeeded is displayed.

    docker login <Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com
    Username: ****@test.com
    Password:
    Login Succeeded
    Note
  2. View the config.json file to confirm your logon information.

    cat ~/.docker/config.json
    {
        "auths": {
            "<Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com": {
                "auth": "****"
            }
        }
    }        

docker pull

The following sample code provides an example on how to download the <Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8 image.

docker pull <Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8
0.8: Pulling from acs/agent
5a026b6c4964: Already exists
e4b621e8d9cb: Already exists
8bc2fd04bdd4: Pull complete
a977b0087b3e: Pull complete
8f6e00ea13c6: Pull complete
875dd8c9666f: Pull complete
9c07bcabc35d: Pull complete
Digest: sha256:cac848bd31bccf2a041bda7b57e3051341093abde6859df9ee9d332dfec6ddd9
Status: Downloaded newer image for <Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8            
Note
  • The domain name that you use to log on to the Container Registry Enterprise Edition instance must be the same as the domain name that you use to access the image. For example, if you log on to the <Name of the Container Registry Enterprise Edition instance> -registry.cn-hangzhou.cr.aliyuncs.com domain name to pull and push images from the <Enterprise Edition instance name>-registry.cn-beijing.cr.aliyuncs.com domain name, an error message is displayed on the client. The error message indicates that you are not authorized to access the image.

  • If you want to pull images from the Docker official website, see Subscribe to image tags from a source repository that resides in a region outside the Chinese mainland.

You can run the docker images command to view the pulled images. Check the repository location and image tags in the command output.

docker images
REPOSITORY                                                     TAG                 IMAGE ID            CREATED             SIZE
<Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent   0.8                 b9ba5841bdb0        24 hours ago        42.18 MB            

docker push

After on-premises images are built or packaged, you can push them to the Container Registry Enterprise Edition instance.

The preparation for pushing images is basically the same as that for pulling images. Make sure that you have the permissions on the repository. Otherwise, the following error messages are returned after you run the command.

docker push <Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8
The push refers to a repository [<Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8]
359f80267111: Layer already exists
7e5fa28d90b8: Layer already exists
b20d7f600f63: Layer already exists
4a159b4f8370: Layer already exists
7c3712ebe877: Layer already exists
d91d130a53aa: Layer already exists
fcad8ad5a40f: Layer already exists
unauthorized: authentication required            

Use a RAM user to log on to a Container Registry Enterprise Edition instance

  1. Log on to the Container Registry console as a RAM user. On the Access Credential page, set the logon password.

  2. Use <RAM user>@<Enterprise alias> as the logon username.

    You can set and view the enterprise alias of an Alibaba Cloud account in the RAM console. If no enterprise alias is available, the enterprise alias is the UID of the Alibaba Cloud account by default.

    Assume that the RAM user is subaccount and the enterprise alias is accoun-alias. The following sample code provides an logon example:

    docker login <Name of the Container Registry Enterprise Edition instance>-registry.cn-hangzhou.cr.aliyuncs.com
    Username: subaccount@account-alias
    Password:
    Login Succeeded