繁体   English   中英

使用 Az CLI 创建新的 Azure 容器实例时,无法从私有 Azure 容器注册表中提取映像

[英]Can't pull image from private Azure Container Registry when using Az CLI to create a new Azure Container Instance

我已经创建了一个服务主体,具有对我的私有 Azure 容器注册表的推送和拉取访问权限。 使用以下命令推送到 ACR 工作得很好:

az login --service-principal -u "someSpID" -p "someSpSecret"  --tenant "someTenantID"
az acr login --name "someRegistry"
docker push "someRegistry.azurecr.io/my-image:0.0.1"

我还可以使用以下命令直接拉取图像:

docker pull "someRegistry.azurecr.io/my-image:0.0.1"

我想将容器实例部署到私有子网中,并且我已经配置了网络安全性以允许访问我的所述子网。

但是,当我尝试使用以下命令将容器实例部署到我的私有子网中时,我在其中指定了我之前登录时使用的相同服务主体,我收到了错误响应。

az container create \
  --name myContainerGroup \
  --resource-group myResourceGroup \
  --image "someRegistry.azurecr.io/my-image:0.0.1" \
  --os-type Linux \
  --protocol TCP \
  --registry-login-server someRegistry.azurecr.io \
  --registry-password someSpSecret \
  --registry-username someSpID \
  --vnet someVNET \
  --subnet someSubnet \
  --location someLocation \
  --ip-address Private

错误:

urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool : https://management.azure.com:443 "PUT /subscriptions/mySubscription/resourceGroups/myResourceGroup/providers/Microsoft.ContainerInstance/containerGroups/myContainerGroup?api-version=2018-10-01 HTTP/1.1" 400
msrest.http_logger : Response status: 400

The image 'someRegistry.azurecr.io/my-image:0.0.1' in container group 'myContainerGroup' is not accessible. Please check the image and registry credential.

当我尝试通过 Azure 门户部署容器实例时,会发生同样的错误。

当我尝试将公共映像部署到同一个子网时,它成功了,所以它不是部署权限问题,它似乎也不是错误的服务主体凭据,因为docker pull "someRegistry.azurecr.io/my-image:0.0.1"工作得很好。 我无法完全理解这种不一致的行为。 任何人的想法?

对于您的问题,这里有一个可能的原因来解释您遇到的错误。 让我们看看这里描述的限制:

只有 Azure Kubernetes 服务集群或 Azure 虚拟机可以作为主机访问虚拟网络中的容器注册表。 目前不支持包括 Azure 容器实例在内的其他 Azure 服务。

此限制表明 Azure 容器注册表的防火墙当前不支持 Azure 容器实例。 它仅支持在 Azure VM 或 AKS 群集中拉/推映像。

因此,您的解决方案是更改规则以允许所有网络,然后重试。 或者使用 AKS 集群,但也会花费更多。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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