Introduction: This article introduces the three most commonly used basic operations of Docker image: login, pull and push, as well as how to log in to a sub account. By understanding the basic operation of mirroring, you can use the container mirroring service ACR more skillfully.
For image download, domain name resolution and time synchronization, please click Alibaba open source mirror station
1, Background information
You need to install Docker before using container image service. For information on how to install Docker, see:
2, docker login
Take Alibaba cloud Hangzhou public network Registry as an example to illustrate how to log in to Docker.
1. Indicate the Registry domain name and enter your user name and login password. Login Succeeded will be displayed after successful login.
docker@default-online:~$ docker login registry.cn-hangzhou.aliyuncs.com Username: sample@alibaba-inc.com Password: Login Succeeded
Note: the login password here is your Mirror warehouse management console Instead of your alicloud login password.
2. Check config JSON file to confirm your login information.
docker@default-online:~$ cat ~/.docker/config.json { "auths": { "registry.cn-hangzhou.aliyuncs.com": { "auth": "XXXXXXXXXXXXXXXXXXXXXX" } } }
3, docker pull
Use the public image of the container service to create a registry cn-hangzhou. aliyuncs. COM / ACS / agent: 0.8 , for example, the command to download the image is as follows:
docker@default-online:~$ docker pull registry.cn-hangzhou.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 registry.cn-hangzhou.aliyuncs.com/acs/agent:0.8
explain:
- If you want to download the official image of Docker, please refer to the accelerator document in the relevant link below.
- If you want to download the image under the public warehouse, you can download it without logging in to Registry.
- The Registry you log in to and the Registry you operate the image must be consistent. For example, only log in to Registry cn-hangzhou. aliyuncs. In the case of COM , push , Registry cn-beijing. aliyuncs. Com image, the client will display an unauthorized error message.
You can use the command below to view the downloaded image (note the warehouse coordinates and Tag).
docker@default-online:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE registry.cn-hangzhou.aliyuncs.com/acs/agent 0.8 b9ba5841bdb0 24 hours ago 42.18 MB
4, docker push
After the image is built or packaged in the local environment, it can be uploaded to the Registry.
The preparation for uploading is basically the same as that for downloading. You need to confirm that you have read-write permission or read-write authorization to this warehouse. Otherwise, you will see the error message below.
docker@default-online:~$ docker push registry.cn-hangzhou.aliyuncs.com/acs/agent:0.8 The push refers to a repository [registry.cn-hangzhou.aliyuncs.com/acs/agent] 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
5, Login sub account
- Use the sub account to log in to the container image service console and set the login password of the corresponding Registry.
- Use [sub account name] @ [enterprise alias] as the user name to log in. You can set and view the enterprise alias of the master account in the RAM console. If there is no enterprise account alias, the default UID is the enterprise account alias.
Assuming that the sub account name is # subaccount and the enterprise alias is # Misaka network, the login example is as follows:
docker@default-online:~$ docker login registry.cn-hangzhou.aliyuncs.com Username: subaccount@misaka-network Password: Login Succeeded
This article is transferred from: Basic operation of Docker image - Alibaba cloud developer community