This topic describes the three most common operations on Docker, namely, docker login, docker pull, and docker push. It 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.
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
NoteYou can obtain the domain name of the Container Registry Enterprise Edition instance on the Access Control page.
The logon password is the password that you set in the Container Registry console, but not the password used to log on to Alibaba Cloud. If you forget the password that you set, you can set an access credential. For more information, see Configure an access credential.
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
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
<Name of the Container Registry Enterprise Edition instance> -registry.cn-hangzhou.cr.aliyuncs.com
only to pull and push images of<Name of the Container Registry Enterprise Edition instance>-registry.cn-beijing.cr.aliyuncs.com
, 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
Log on to the Container Registry console as a RAM user. On the Access Credential page, set the logon password.
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 isaccoun-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