azure-devops - 使用 devops 将 docker 镜像推送到私有(private) azure 容器注册表

标签 azure-devops azure-virtual-network azure-container-registry

所以我有一个私有(private) Azure 容器注册表,它本质上也位于私有(private) VNET 上(它必须这样做)。

我已将我的私有(private)容器注册表配置为:

"Allow trusted Microsoft services to access this container registry"

我还在我的 VENT 中允许 Microsoft Container registry 作为服务端点。

但是,当我使用以下代码在 devops 中推送我的图像时:

  variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: 'myacr'
  imageRepository: 'my-image-repo'
  containerRegistry: 'myacr.azurecr.io'
  dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
  tag: '$(Build.BuildId)'
 steps:
- task: Docker@2
  displayName: Login to ACR
  inputs:
    command: login
    containerRegistry: $(dockerRegistryServiceConnection)
- task: Docker@2
  displayName: Build image with arguments
  inputs:
    command: build
    arguments: --build-arg git_personal_token=MYTOKEN
    repository: $(imageRepository)
    dockerfile: $(dockerfilePath)
    containerRegistry: $(dockerRegistryServiceConnection)
    tags: |
      $(tag)
- task: Docker@2
  displayName: push the image
  inputs:
    containerRegistry: $(dockerRegistryServiceConnection)
    repository: $(imageRepository)
    command: push
    tags: |
      $(tag)

我得到错误:

denied: client with IP '51.145.2.107' is not allowed access. Refer https://aka.ms/acr/firewall to grant access.

但是,我无法在防火墙中设置 IP 地址,因为构建器 IP 会随着生成的每个唯一构建而变化。我以为我已经允许所有 Microsoft 服务正确访问,我是否遗漏了什么,或者我该如何进一步调试?

最佳答案

如果您有一个 Azure 容器注册表,您在其中禁用了公共(public)网络访问,您将无法从 Microsoft Hosted Azure Devops Agent 访问它。 .

Trusted services当前仅包含少量服务,但将来可能会添加更多服务:

  • Azure Container Instances
  • Microsoft Defender for Cloud
  • ACR Tasks
  • Machine Learning
  • Azure Container Registry

但是,不太可能添加 Azure DevOps(至少不是代理),因为 Microsoft 无法控制其中执行的代码(因此它们不受信任)。同样的原则适用于 Azure DevOps service tag ,其中不包括 Microsoft 托管代理。

如果您真的需要您的注册表完全私有(private),您将需要使用 self hosted agent部署在您自己的网络中,可以访问注册表。

关于azure-devops - 使用 devops 将 docker 镜像推送到私有(private) azure 容器注册表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73444626/

相关文章:

用于创建服务主体的 Azure 函数

powershell - 使用 Powershell 以纯文本形式获取 Azure Devops secret 变量

Azure Key Vault - 从 Key Vault 下载原始 PFX

azure - 如何让 Azure Devops 识别订阅连接具有新的访问 token ?

azure - Cosmos Db 到应用服务 VNet 集成

Azure DevOps Pipeline yaml 文件 Docker 标签

tfs - 在 Visual Studio Team Service 中创建具有未分配错误的查询

azure - 从 Azure VM 访问互联网无法正常工作

ios - 来自 IOS/iPad/IPhone 的 Azure 点到站点 VPN 连接

powershell - 输出返回 ACR 中存储库数量的错误结果