首页 > 解决方案 > 将 ACR 用作容器资源

问题描述

在 Azure Devops 中,您可以使用“容器资源”在容器中运行管道,我正在尝试使用我推送到私有 acr 存储库的容器,但我终其一生都找不到任何可以连接它的东西. 我已经设置了一个“服务连接”并允许管道使用它。这是资源部分:

resources:
  containers:
  - container: infrastructure
    image: <acr-registry>.azurecr.io/<private-image>
    env:
      ARM_ACCESS_KEY: "$(arm_access_key)"
      ARM_CLIENT_ID: "$(arm_client_id)"
      ARM_CLIENT_SECRET: "$(arm_client_secret)"
      ARM_SUBSCRIPTION_ID: "$(arm_subscription_id)"

现在根据这个你必须指定你想使用“服务连接” https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml但在 yaml 文档中(https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#resources)我看不到任何地方可以指定服务连接在资源部分使用

标签: azureazure-devopsazure-container-registry

解决方案


如果你想在构建过程中使用容器,可以按照官方文档:

resources:
  containers:
  - container: string  # identifier (A-Z, a-z, 0-9, and underscore)
    image: string  # container image name
    options: string  # arguments to pass to container at startup
    endpoint: string  # endpoint for a private container registry
    env: { string: string }  # list of environment variables to add
    ports: [ string ] # ports to expose on the container
    volumes: [ string ] # volumes to mount on the container

您需要使用端点来指定要使用的 docker 注册表连接

https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#resources


推荐阅读