Azure ACR任务无法从Azure容器注册表中提取Docker映像

时间:2020-06-02 12:19:33

标签: azure docker azure-container-registry

我正在关注this文章。 我有一个Azure容器注册表,如下图所示,并且定义了如下任务。

az acr task create \
--name krushnaTask \
--registry krushna \
--cmd python-hello \
--schedule "1 10 * * *" \
--context /dev/null

Azure运行任务时,出现以下错误:

2020/06/02 11:02:03 Alias support enabled for version >= 1.1.0, please see https://aka.ms/acr/tasks/task-aliases for more information.
2020/06/02 11:02:03 Creating Docker network: acb_default_network, driver: 'bridge'
2020/06/02 11:02:03 Successfully set up Docker network: acb_default_network
2020/06/02 11:02:03 Setting up Docker configuration...
2020/06/02 11:02:04 Successfully set up Docker configuration
2020/06/02 11:02:04 Logging in to registry: krushna.azurecr.io
2020/06/02 11:02:05 Successfully logged into krushna.azurecr.io
2020/06/02 11:02:05 Executing step ID: acb_step_0. Timeout(sec): 3600, Working directory: '', Network: 'acb_default_network'
2020/06/02 11:02:05 Launching container with name: acb_step_0
Unable to find image 'python-hello:latest' locally
docker: Error response from daemon: pull access denied for python-hello, repository does not   exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
2020/06/02 11:02:05 Container failed during run: acb_step_0. No retries remaining.
failed to run step ID: acb_step_0: exit status 125

该怎么做才能使ACR任务可以访问docker映像?

Azure ACR repo image Azure ACR task details

2 个答案:

答案 0 :(得分:1)

我非常确定问题是您需要将图像输入为krushna.azurecr.io/python-hello:tag,因为该图像位于您的ACR中。当您将映像输入为python-hello时,这意味着它是Docker Hub中的公共Docker映像,因此由于在Docker Hub中找不到该映像而导致了错误。像下面这样更改命令,它将正常运行:

az acr task create \
--name krushnaTask \
--registry krushna \
--cmd krushna.azurecr.io/python-hello \
--schedule "1 10 * * *" \
--context /dev/null

答案 1 :(得分:0)

创建ACR任务时,如果您的注册表启用了RBAC,则应提供git-access-token

--git-access-token
The access token used to access the source control provider.

https://docs.microsoft.com/en-us/cli/azure/acr/task?view=azure-cli-latest#az-acr-task-create

您可以从此DOC创建访问令牌

https://docs.microsoft.com/en-us/azure/container-registry/container-registry-tutorial-quick-task#configure-registry-authentication