# 筆記 - 將 imgae 部署到 Azure Azure service: 1. Container registries 2. Container instances ## Create container registry - Service 搜尋 Container registries 並進入頁面  - 點選 「Create」 創建 Azure Container Registry  新增後,從列表點選剛剛新增的 ACR (Azure container registry),進入詳細資訊頁面  > 留意你的 Registry name,接下來指令的步驟會以 `your-acr-name` 表示 ### Push an image  點選之後會跳出教學,顯示如何從本地將 image 推到 Azure 的服務上 接下來會使用到 Docker CLI 和 Azure CLI Docker CLI:下載 [Docker Desktop](https://www.docker.com/products/docker-desktop/) Azure CLI:下載 [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) ### 登入 Azure ```= az login ``` 這個步驟會跳出 Microsoft 的登入視窗 > 若安裝完 Azure CLI 後,仍找不到 az 指令,可以重新開機讓系統更新一下 登入後會顯示目前有的 Subscription  接著選擇一個 Subscription ,記得此處要輸入的是「編號」 ### 登入 ACR 在執行下方指令前,需要先確定 Docker desktop 有開啟,因為登入過程系統會使用到 docker,不然會跳出錯誤訊息  確認 docker 有啟動之後 ```= az acr login --name your-acr-name ``` 若有成功會顯示 Login Succeeded  ### 標記本地要上傳的 Image 如果你最新的 Image 不在本地,請先 Pull 下來 ```= docker pull image-repository:tag ``` 本地是最新的之後,將上傳的 Image 設定新的標籤,像是 `your-acr-name.azurecr.io/file`,表示這個 Image 要上傳到 ACR 的 file 目錄 這個目錄只是為了管理 Image,不會影響部署後的網址 ```= docker tag your-image-id your-acr-name.azurecr.io/file/image-repository:tag ``` ### 上傳 Image ```= docker push your-acr-name.azurecr.io/file/image-repository:tag-name ```  ### 確認 Image 是否已經上傳 ```= az acr repository list --name your-acr-name --output table ```  如果要看 Image 的標籤 ```= az acr repository show-tags --name your-acr-name --repository file/image-repository --output table ```  如果剛剛設定的 tag 有存在,表示 Image 已成功 push 上去 ## Create container instance 設定基本資訊 Resource group: your-resource-group Container name: your-app-inst Region: 選擇你的地區 Image source: Azure Container Registry Registry: 選擇你的 ACR Image: 選擇剛剛上傳的 image Image tag: 選擇正確最新的 tag 其他有需要則按照需求調整 #### Image 和 Image tag 是唯讀無法選取 常見原因是你的 ACI 沒有權限存取 ACR,請授權給 ACI,這樣 ACI 才能拉取 ACR 內的 Image ```= az acr update --name your-acr-name --admin-enabled true ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up