英文:
ACR purge task using terraform not working as expected
问题
创建类似于下面的 ACR:
resource "azurerm_container_registry" "acr" {
name = var.azure_container_registry_name
resource_group_name = var.resource_group.name
location = var.location
}
以及下面的清理任务:
resource "azurerm_container_registry_task" "acr_purge_task" {
name = "scheduledAcrPurgeTask"
container_registry_id = azurerm_container_registry.acr.id
platform {
os = "Linux"
}
encoded_step {
task_content = <<EOF
version: v1.1.0
steps:
- cmd: acr purge --filter 'REPO:TEST.*' --untagged --ago 10m
disableWorkingDirectoryOverride: true
timeout: 3600
EOF
context_path = "/dev/null"
}
timer_trigger {
name = "t1"
schedule = "*/15 * * * *"
enabled = true
}
}
任务成功创建,但在运行时出现以下错误:
无法在本地找到'image 'acr:latest'
docker: 守护程序的错误响应: 对于 acr,拉取访问被拒绝,存储库不存在或可能需要 'docker login':请求的访问被拒绝。
我不确定为什么它尝试在 acr:latest
中查找映像,因为我正在维护 REPO
作为我的存储库。
英文:
Creating ACR like below
resource "azurerm_container_registry" "acr" {
name = var.azure_container_registry_name
resource_group_name = var.resource_group.name
location = var.location
}
And purge task like below
resource "azurerm_container_registry_task" "acr_purge_task" {
name = "scheduledAcrPurgeTask"
container_registry_id = azurerm_container_registry.acr.id
platform {
os = "Linux"
}
encoded_step {
task_content = <<EOF
version: v1.1.0
steps:
- cmd: acr purge --filter 'REPO:TEST.*' --untagged --ago 10m
disableWorkingDirectoryOverride: true
timeout: 3600
EOF
context_path = "/dev/null"
}
timer_trigger {
name = "t1"
schedule = "*/15 * * * *"
enabled = true
}
}
The task is getting creating successfully but when ran I am getting below error
Unable to find image 'acr:latest' locally
docker: Error response from daemon: pull access denied for acr, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
I am not sure why this is trying to find image in acr:latest as I am maintaining REPO as my repository.
答案1
得分: 1
我移除了行前的空格
version: v1.1.0
steps:
- cmd: acr purge --filter 'REPO:TEST.*' --untagged --ago 10m
disableWorkingDirectoryOverride: true
timeout: 3600
之前
version: v1.1.0
steps:
- cmd: acr purge --filter 'REPO:TEST.*' --untagged --ago 10m
disableWorkingDirectoryOverride: true
timeout: 3600
我不知道为什么terraform或Azure都没有提供更好的错误响应。
英文:
Silly mistake
I removed the empty spaces before lines
version: v1.1.0
steps:
- cmd: acr purge --filter 'REPO:TEST.*' --untagged --ago 10m
disableWorkingDirectoryOverride: true
timeout: 3600
earlier
version: v1.1.0
steps:
- cmd: acr purge --filter 'REPO:TEST.*' --untagged --ago 10m
disableWorkingDirectoryOverride: true
timeout: 3600
I don't why terraform or either the Azure didn't provide better error response.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论