azure - 使用 Az CLI 创建新的 Azure 容器实例时,无法从私有(private) Azure 容器注册表中提取镜像

标签 azure azure-cli azure-container-instances azure-container-registry

我创建了一个服务主体,可以对我的私有(private) 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"

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

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

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 门户部署容器实例时,会出现同样的错误。

当我尝试将公共(public)镜像部署到同一子网中时,它成功地成功,因此这不是部署权限问题,也不是错误的服务主体凭据,因为docker pull“someRegistry.azurecr。 io/my-image:0.0.1" 工作得很好。我无法完全理解这种不一致的行为。有人有想法吗?

最佳答案

对于您的问题,以下是解释您遇到的错误的可能原因。让我们看看限制描述 here :

Only an Azure Kubernetes Service cluster or Azure virtual machine can be used as a host to access a container registry in a virtual network. Other Azure services including Azure Container Instances aren't currently supported.

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

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

关于azure - 使用 Az CLI 创建新的 Azure 容器实例时,无法从私有(private) Azure 容器注册表中提取镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59988995/

相关文章:

Azure acs ssh 登录持续失败,错误代码为 "permission denied (public key)"

azure-container-instances - 与 Azure 容器实例中的容器交互

使用 APIM 验证 Azure OpenAI Swagger 失败

python-3.x - 如何使用任务来命中在 azure 批处理节点中运行的 flask 应用程序?

git - Azure cli 存储库导入失败,操作返回 400 状态代码

azure - 我可以同时从同一台计算机使用 azure-cli 访问多个 azure 帐户吗?

azure - 使用虚拟网络部署容器实例的步骤

重新部署时 Azure ACI 专用 IP 发生变化

c# - 使用 API 删除和重新创建数据库时,Azure Cosmos DB 上的存储设置不断从“无限制”更改为“固定”

azure - Xamarin Forms 和 Azure Easy Tables 同步问题