使用Terraform从私有DockerHub repo在Azure上部署容器

使用Terraform从私有DockerHub repo在Azure上部署容器,azure,docker,terraform,Azure,Docker,Terraform,我正在从存储在DockerHub中的容器和映像向Azure部署应用程序。当我在DockerHub中部署存储库时,它是公共的,因此我可以轻松地部署它。但是,我希望存储库是私有的,并且仍然能够部署它。我可以通过某种方式将DockerHub的凭据传递到terraform配置吗 目前,这就是我用来部署容器的方法。这一切都是可行的,但我真的希望回购协议是私人的 resource "azurerm_container_group" "cg" { name

我正在从存储在DockerHub中的容器和映像向Azure部署应用程序。当我在DockerHub中部署存储库时,它是公共的,因此我可以轻松地部署它。但是,我希望存储库是私有的,并且仍然能够部署它。我可以通过某种方式将DockerHub的凭据传递到terraform配置吗

目前,这就是我用来部署容器的方法。这一切都是可行的,但我真的希望回购协议是私人的

resource "azurerm_container_group" "cg" {
  name                = "mycontainer"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  ip_address_type     = "public"
  dns_name_label      = "mycontainer"
  os_type             = "Linux"

  container {
    name   = "mycontainer"
    image  = "myuser/myimage:tag"
    cpu    = "0.5"
    memory = "1.5"

    ports {
      port     = 80
      protocol = "TCP"
    }
  }
}

您只需将
azurerm\u container\u组的属性添加到您的私人注册表凭据中,如下所示:

resource "azurerm_container_group" "cg" {
  name                = "mycontainer"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  ip_address_type     = "public"
  dns_name_label      = "mycontainer"
  os_type             = "Linux"

  container {
    name   = "mycontainer"
    image  = "myuser/myimage:tag"
    cpu    = "0.5"
    memory = "1.5"

    ports {
      port     = 80
      protocol = "TCP"
    }
  }

  image_registry_credential {
    username = "xxx"
    password = "xxx"
    server   = "server_url"
  }
}
图像需要:
“serverurl/username/myimage:tag”

我收到这个错误
原始错误:code=“不可访问图像”消息=“无法访问容器组“mycontainer”中的图像“myuser/myimage:tag”。
。我正在使用正确的凭据和
hub.docker.com
作为服务器url@everspader可能图像名称不正确。您可以尝试检查是否可以在本地登录私有注册表并提取图像。图像名称是否正确。我是存储图像的回购协议的所有者,因此我在玩弄它,当我的回购协议没有
image\u registry\u凭证
块时,可以拉取图像,但当回购是私有的,且块已打开时,不能拉取图像credentials@everspader你能给我一张你私人注册的带有标签的图片截图吗?我用截图编辑了这篇文章。