![](/img/trans.png)
[英]How to pull container image from docker registry to deploy azure container
[英]Azure - how do I Docker exec into container with a Container Registry?
我想將docker exec
到 Azure 托管的容器中。
然而,在 Azure 中似乎有幾種托管容器的方法,而且我發現的大多數指南和信息似乎都引用了我們如何設置它的不同方法。
由於圖像被添加為“容器注冊表”中的“回購”,我們的容器正在運行。 除此之外,Azure 中還有稱為容器組和容器實例的東西,據我所知,這兩者都與我的設置無關。
那么我怎樣才能執行到以這種方式托管的容器中呢?
如本 MS 指南所述,這是我嘗試過的方法,但同樣,這似乎假定容器組/容器實例方法,而不是我的設置。
az container exec --resource-group unitsnew --name unitsreg --exec-command "whatever"
unitsnew
是我的資源組的名稱, unitsreg
是我在容器注冊表中的 repo 名稱(我也嘗試過為此 arg 傳遞注冊表本身的名稱。)
因此,這是行不通的; 有人告訴我:
(ResourceNotFound) 資源“Microsoft.ContainerInstance/containerGroups/unitsreg”。 在資源組“unitsnew”下未找到。 有關詳細信息,請撥打 go 至https://aka.ms/ARMResourceNotFoundFix代碼:ResourceNotFound 消息:未找到資源組“unitsnew”下的資源“Microsoft.ContainerInstance/containerGroups/unitsreg”。 欲了解更多詳情,請撥打 go 至https://aka.ms/ARMResourceNotFoundFix
[ - - 編輯 - - ]
設置信息。
appslot 將其“源”(在部署中心 > 設置下)設置為“容器注冊表”。
注冊表設置為:
bin/rails server --port 3000 --binding 0.0.0.0
正如我所說,這與具有以下 YAML 的 Devops 管道相關聯:
# Docker
# Build and push an image to Azure Container Registry
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- my-gh-branch
resources:
- repo: self
variables:
imageRepository: 'panstudiohellolamppostapi_web'
containerRegistry: '<redacted>.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: 'latest'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: DockerCompose@0
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'Microsoft Azure Sponsorship(<redacted>)'
azureContainerRegistry: '{"loginServer":"<redacted>.azurecr.io", "id" : "/subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.ContainerRegistry/registries/<redacted>"}'
dockerComposeFile: '**/docker-compose.yml'
action: 'Run a Docker Compose command'
dockerComposeCommand: 'build'
- task: DockerCompose@0
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'Microsoft Azure Sponsorship(<redacted>)'
azureContainerRegistry: '{"loginServer":"<redacted>.azurecr.io", "id" : "/subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.ContainerRegistry/registries/<redacted>"}'
dockerComposeFile: '**/docker-compose.yml'
action: 'Push services'
據我了解,錯誤消息引起了轟動。 az 正在尋找容器組的正在運行的容器。
正如您所看到的,az 提供的幫助消息:
az container exec
the following arguments are required: --exec-command
Examples from AI knowledge base:
az container exec --exec-command "/bin/bash" --name mynginx --resource-group MyResourceGroup
Execute a command from within a running container of a container group. (autogenerated)
az container exec --resource-group MyResourceGroup --name mynginx --container-name nginx --exec-command "/bin/bash"
Stream a shell from within an nginx container.
https://learn.microsoft.com/en-US/cli/azure/container#az_container_exec
Read more about the command in reference docs
az container exec --resource-group MyResourceGroup --name mynginx --container-name nginx --exec-command "/bin/bash"
Stream a shell from within an nginx container.
https://learn.microsoft.com/en-US/cli/azure/container#az_container_exec
Read more about the command in reference docs
據我了解,您只將圖像推送到 azure ACR。 將圖像推送到 Azure ACR 不足以讓容器運行,Azure ACR 功能類似於 Dockerhub,它存儲您的工件,例如 docker 圖像。 如果你想讓你的圖像運行,你可以使用容器組https://learn.microsoft.com/en-us/azure/container-instances/container-instances-container-groups 。
希望有所幫助:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.