我正在使用地形为我在Azure的项目提供基础设施。
基础设施的一部分是一个容器注册表,用于存储库kubernates将要使用的坞映像。因为目前所有的东西都是使用地形提供的,所以我也在努力构建和推进这些图像。我找到了kreuzwerker/docker提供者,它也许可以完成这项工作。
目前,我有这样的代码:
provider "docker" {
registry_auth {
address = azurerm_container_registry.example.login_server
username = azurerm_container_registry.example.admin_username
password = azurerm_container_registry.example.admin_password
}
}
resource "docker_registry_image" "example" {
name = "example"
keep_remotely = false
build {
context = path.cwd
dockerfile = "Dockerfile"
}
}该映像似乎已经生成,但当将其推到注册表时,我会得到以下错误:
╷
│ Error: resourceDockerRegistryImageCreate: Unable to get authConfig for registry: no auth config found for registry registry-1.docker.io in auth configs: map[string]types.AuthConfig{"***.azurecr.io":types.AuthConfig{Username:"***", Password:"***", Auth:"", Email:"", ServerAddress:"https://***.azurecr.io", IdentityToken:"", RegistryToken:""}}
│
│ with docker_registry_image.backend,
│ on docker.tf line 1, in resource "docker_registry_image" "backend":
│ 1: resource "docker_registry_image" "backend" {
│
╵我认为这是在试图推进到registry-1.docker.io,但这不是正确的注册表。所以我试着
provider "docker" {
host = azurerm_container_registry.example.login_server
registry_auth {
address = azurerm_container_registry.example.login_server
username = azurerm_container_registry.example.admin_username
password = azurerm_container_registry.example.admin_password
}
}但是我得到了这个错误:
╷
│ Error: Error initializing Docker client: unable to parse docker host `***.azurecr.io`
│
│ with provider["registry.terraform.io/kreuzwerker/docker"],
│ on provider.tf line 8, in provider "docker":
│ 8: provider "docker" {
│
╵如何使用此提供程序将映像推送到正确的ACR?
发布于 2022-10-09 14:58:19
对于停靠者图像,如果图像实际上定义了将用于将图像推送到(或从中获取图像)的注册表,则为名称。因此,当您将图像名定义为example时,默认情况下它将转到DockerHub。
为了将图像发送到您自己的注册中心,无论在哪里,注册表域都必须加到图像名称的前面,如反加密的这里。
在上面的链接中的一个例子中,mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine将被推送到注册表mcr.microsoft.com而不是DockerHub。
https://stackoverflow.com/questions/74002241
复制相似问题