Learn how to use docker login, docker pull, and docker push with Container Registry (ACR) Enterprise Edition instances.
Prerequisites
-
Docker is installed. Install and use Docker and Docker Compose.
-
A Container Registry Enterprise Edition instance is created. Create an Enterprise Edition instance.
docker login
The following example logs in to an Enterprise Edition instance in the China (Hangzhou) region.
-
Run the login command with your Enterprise Edition instance domain name. Enter your username and password when prompted.
Note-
The domain name for the Enterprise Edition instance uses the format
<instance-name>-registry.cn-hangzhou.cr.aliyuncs.com. To find the domain name, log on to the Container Registry console and go to the Access Control page. -
The logon password differs from your Alibaba Cloud account password. Configure access credentials.
On success,
Login Succeededis displayed.docker login <instance-name>-registry.cn-hangzhou.cr.aliyuncs.com Username: ****@test.com Password: Login Succeeded -
-
Verify your login credentials in config.json.
Run the following command:
cat ~/.docker/config.jsonExpected output:
{ "auths": { "<instance-name>-registry.cn-hangzhou.cr.aliyuncs.com": { "auth": "****" } } }
docker pull
The following example pulls the image <instance-name>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8.
Run the following command:
docker pull <instance-name>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8
Expected output:
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 <instance-name>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8
-
The login domain must match the image registry domain. If you are logged in to
<instance-name>-registry.cn-hangzhou.cr.aliyuncs.com, pulling or pushing from<instance-name>-registry.cn-beijing.cr.aliyuncs.comreturns an unauthorized error. -
Use artifact subscription to pull images from overseas sources.
Run docker images to list downloaded images. Note the repository name and tag.
docker images
Expected output:
REPOSITORY TAG IMAGE ID CREATED SIZE
<instance-name>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent 0.8 b9ba5841bdb0 24 hours ago 42.18 MB
docker push
Push locally built images to your Enterprise Edition instance.
You must have the required repository permissions. Otherwise, the push fails with an authentication error.
Run the following command:
docker push <instance-name>-registry.cn-hangzhou.cr.aliyuncs.com/acs/agent:0.8
The following output indicates that the push failed due to an authentication error:
The push refers to a repository [<instance-name>-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
Log on as a RAM user
-
As a RAM user, log on to the Container Registry console and go to the Access Credentials page to set a logon password.
-
Use
[RAM username]@[enterprise alias]as the username to log on.Set or view the enterprise alias in the RAM console. If no enterprise alias is set, the Alibaba Cloud account UID is used by default.
For example, if the RAM username is
subaccountand the enterprise alias isaccount-alias:docker login <instance-name>-registry.cn-hangzhou.cr.aliyuncs.com Username: subaccount@account-alias Password: Login Succeeded