iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 7
2

本篇筆記將介紹如何將 Image 發佈到 Azure Container Registry (ACR), 發佈到 Azure 上後, 其他 Team 便可以共同存取 ACR 上的 Image. 廢話不多說, 開始吧!

發布 Image 到 Azure Container Registry

  1. 首先使用 az login 命令登入 Azure
    以下部分資訊將會遮罩起來.
Note, 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"
    }
  }
]
  1. 使用命令 **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
}
  1. 使用命令 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"
}
  1. 可以使用命令 Az acr list -o table 列出已經建立好的 ACR
NAME       RESOURCE GROUP    LOCATION       SKU    LOGIN SERVER          CREATION DATE         ADMIN ENABLEDistry/registries"
---------  ----------------  -------------  -----  --------------------  --------------------  ---------------
15maksacr  15maksrg          southeastasia  Basic  15maksacr.azurecr.io  2018-10-14T06:27:45Z
  1. 使用命令 az acr login -n 15maksacr 登入 ACR
Login Succeeded
  1. 使用命令 docker image list 列出 docker images
REPOSITORY                                 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
以下略...
  1. 使用命令 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
以下略…
  1. 接下來用命令 docker push 15maksacr.azurecr.io/aspnetapp:v1 將 Image 推送到 ACR
The 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
  1. 使用命令 az acr repository list -n 15maksacr 確認 ACR 裡的 repository
[
  "aspnetapp"
]

大功告成了, 我們成功將 image 放到 ACR 上了.


參考資料:


上一篇
Day 6 - 淺談 Azure Kubernetes Service, Azure Container Registry, Azure Container Instance
下一篇
Day 8 - 建立 Azure Kubernetes Service (AKS) 叢集
系列文
15 分鐘學習系列 - 第一次學 Kubernetes 就上手30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言