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