本篇筆記將介紹如何將 Image 發佈到 Azure Container Registry (ACR), 發佈到 Azure 上後, 其他 Team 便可以共同存取 ACR 上的 Image. 廢話不多說, 開始吧!
az login
命令登入 AzureNote, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code"
You have logged in. Now let us find all the subscriptions to which you have access...
[
{
"cloudName": "AzureCloud",
"id": "11e5233d-dbe1-4167-ac91-????????????",
"isDefault": true,
"name": "Visual Studio Ultimate with MSDN",
"state": "Enabled",
"tenantId": "293a593f-cc57-451b-b293-????????????",
"user": {
"name": "??????@????.com",
"type": "user"
}
},
{
"cloudName": "AzureCloud",
"id": "4424e4b1-fb5f-4ad7-8664-????????????",
"isDefault": false,
"name": "Access to Azure Active Directory",
"state": "Disabled",
"tenantId": "293a593f-cc57-451b-b293-????????????",
"user": {
"name": "??????@????.com",
"type": "user"
}
}
]
az group create -n 15maksrg -l southeastasia
**在 Azure 上建立一個 Resource group{
"id": "/subscriptions/11e5233d-dbe1-4167-ac91-????????????/resourceGroups/15maksrg",
"location": "southeastasia",
"managedBy": null,
"name": "15maksrg",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null
}
az acr create -n 15maksacr -g 15maksrg -l southeastasia --sku basic
建立 ACR, Azure Container Registry 提供 4 種不同的 sku, 我們選擇練習用的 Basic 來創建{
"adminUserEnabled": false,
"creationDate": "2018-10-14T06:27:45.022863+00:00",
"id": "/subscriptions/11e5233d-dbe1-4167-ac91-????????????/resourceGroups/15maksrg/providers/Microsoft.ContainerRegistry/registries/15maksacr",
"location": "southeastasia",
"loginServer": "15maksacr.azurecr.io",
"name": "15maksacr",
"provisioningState": "Succeeded",
"resourceGroup": "15maksrg",
"sku": {
"name": "Basic",
"tier": "Basic"
},
"status": null,
"storageAccount": null,
"tags": {},
"type": "Microsoft.ContainerRegistry/registries"
}
Az acr list -o table
列出已經建立好的 ACRNAME RESOURCE GROUP LOCATION SKU LOGIN SERVER CREATION DATE ADMIN ENABLEDistry/registries"
--------- ---------------- ------------- ----- -------------------- -------------------- ---------------
15maksacr 15maksrg southeastasia Basic 15maksacr.azurecr.io 2018-10-14T06:27:45Z
az acr login -n 15maksacr
登入 ACRLogin Succeeded
docker image list
列出 docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE
aspnetapp local eacdf855a63c 4 days ago 257MB
<none> <none> d5f0b8ddb472 4 days ago 1.75GB
microsoft/dotnet 2.1-sdk efa6f1f55357 4 days ago 1.73GB
microsoft/dotnet 2.1-aspnetcore-runtime 70c1124a9a02 4 days ago 255MB
hello-world latest 4ab4c602aa5e 5 weeks ago 1.84kB
ubuntu latest cd6d8154f1e1 5 weeks ago 84.1MB
以下略...
docker tag
將本機的 image 設定 tag, 再次使用命令 docker image list
確認docker tag aspnetapp:local 15maksacr.azurecr.io/asp
netapp:v1
docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
15maksacr.azurecr.io/aspnetapp v1 eacdf855a63c 4 days ago 257MB
aspnetapp local eacdf855a63c 4 days ago 257MB
以下略…
docker push 15maksacr.azurecr.io/aspnetapp:v1
將 Image 推送到 ACRThe push refers to repository [15maksacr.azurecr.io/aspnetapp]
0106321d1a9e: Pushed
cd1be85f4c90: Pushed
d00d2c8144b6: Pushed
108fa49df6c1: Pushed
ddd4c04722d5: Pushed
8b15606a9e3e: Pushed
v1: digest: sha256:aec3a7618545affc6c1174248e6b2f99afb9a0ded0148267018d76b191623fb4 size: 1580
az acr repository list -n 15maksacr
確認 ACR 裡的 repository[
"aspnetapp"
]
大功告成了, 我們成功將 image 放到 ACR 上了.
參考資料: