简体   繁体   中英

How to pull container image from docker registry to deploy azure container

I am currently working in a azure project where we need a way to push the image to public registries - it can be Azure ACR or docker registry.

Looks like Azure doesnt support anonymous read-access to Azure ACR. Hence only way is to push image to docker registry and pull the image form docker registry during container deployment in azure.

Is it possible? If so, how can I use azure template to achieve it? Any example please?

I thinks it is possible to create the azure container by using imageRegistryCredentials property, you could refer to the sample template.

{
  "name": "string",
  "type": "Microsoft.ContainerInstance/containerGroups",
  "apiVersion": "2018-04-01",
  "location": "string",
  "tags": {},
  "properties": {
    "containers": [
      {
        "name": "string",
        "properties": {
          "image": "string",
          "command": [
            "string"
          ],
          "ports": [
            {
              "protocol": "string",
              "port": "integer"
            }
          ],
          "environmentVariables": [
            {
              "name": "string",
              "value": "string"
            }
          ],
          "resources": {
            "requests": {
              "memoryInGB": "number",
              "cpu": "number"
            },
            "limits": {
              "memoryInGB": "number",
              "cpu": "number"
            }
          },
          "volumeMounts": [
            {
              "name": "string",
              "mountPath": "string",
              "readOnly": boolean
            }
          ]
        }
      }
    ],
    "imageRegistryCredentials": [
      {
        "server": "string",
        "username": "string",
        "password": "string"
      }
    ],
    "restartPolicy": "string",
    "ipAddress": {
      "ports": [
        {
          "protocol": "string",
          "port": "integer"
        }
      ],
      "type": "Public",
      "ip": "string",
      "dnsNameLabel": "string"
    },
    "osType": "string",
    "volumes": [
      {
        "name": "string",
        "azureFile": {
          "shareName": "string",
          "readOnly": boolean,
          "storageAccountName": "string",
          "storageAccountKey": "string"
        },
        "emptyDir": {},
        "secret": {},
        "gitRepo": {
          "directory": "string",
          "repository": "string",
          "revision": "string"
        }
      }
    ]
  }
}

For more details, you could refer to this link .

在此处输入图片说明

If the image is public , the password is not required.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM