练习 - 将容器映像复制到不同的 Azure 区域

已完成

假设已将计算工作负载部署到多个区域。 可以使用 Azure 容器注册表将容器注册表放置在运行映像的每个区域中。 此策略允许网络关闭操作,并支持快速可靠的图像层传输。

异地复制允许容器注册表充当单个注册表,向多个区域提供多主区域注册表。

异地复制注册表有以下优点:

  • 跨多个区域使用单个注册表/映像/标记的名称。
  • 由区域部署实现近网络注册表访问。
  • 由于是从与容器主机处于相同区域的本地复制注册表中拉取映像,因此无额外传输费用。
  • 跨多个区域对注册表进行单一管理。

为 Azure 容器注册表创建重复的区域

  1. 使用 az acr replication create 命令将注册表复制到另一个区域。 在此示例中,我们将复制到 japaneast 区域。

    az acr replication create --registry $ACR_NAME --location japaneast
    

    输出应该类似于以下简洁示例输出:

    {
      ...
      resourceGroups/learn-acr-rg/providers/Microsoft.ContainerRegistry/registries/myuniqueacrname/replications/japaneast",
      "location": "japaneast",
      "name": "japaneast",
      "provisioningState": "Succeeded",
       "regionEndpointEnabled": true,
       "resourceGroup": "learn-acr-rg",
      ...
    }
    
  2. 使用 az acr replication list 命令查看所有容器映像副本。

    az acr replication list --registry $ACR_NAME --output table
    

    输出应类似于以下示例输出:

    NAME       LOCATION    PROVISIONING STATE    STATUS    REGION ENDPOINT ENABLED
    ---------  ----------  -------------------   -------   ------------------------
    japaneast  japaneast   Succeeded             Ready     True
    eastus     eastus      Succeeded             Ready     True
    

还可以导航到容器注册表并选择 Replications 来使用 Azure 门户查看容器映像:

Screenshot of Azure container registry world map showing replicated and available locations.

清理资源

删除在此模块中创建的资源,以避免产生费用。 删除资源组还会删除其所有关联资源。

  1. 导航到 Azure Cloud Shell

  2. 使用 az group delete 命令删除资源组。

    az group delete --name learn-acr-rg --yes --no-wait 
    

了解详细信息

使用以下资源详细了解 Azure 上的 Azure 容器注册表和 Docker: