resources.containers.container 定义

容器资源引用容器映像。

containers:
- container: string # Required as first property. Alias of the container.
  image: string # Required. Container image tag.
  type: string # Type of the registry like ACR or GCR.
  trigger: trigger | none | true # Specify none to disable, true to trigger on all image tags, or use the full syntax as described in the following examples.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  env: # Variables to map into the container's environment.
    string: string # Name/value pairs
  mapDockerSocket: boolean # Set this flag to false to force the agent not to setup the /var/run/docker.sock volume on container jobs.
  options: string # Options to pass into container host.
  ports: [ string ] # Ports to expose on the container.
  volumes: [ string ] # Volumes to mount on the container.
  mountReadOnly: # Volumes to mount read-only, the default is all false.
    work: boolean # Mount the work directory as readonly.
    externals: boolean # Mount the externals directory as readonly.
    tools: boolean # Mount the tools directory as readonly.
    tasks: boolean # Mount the tasks directory as readonly.
  azureSubscription: string # Azure subscription (ARM service connection) for container registry.
  resourceGroup: string # Resource group for your ACR.
  registry: string # Registry for container images.
  repository: string # Name of the container image repository in ACR.
  localImage: boolean # When true, uses a locally tagged image instead of using docker pull to get the image. The default is false.
containers:
- container: string # Required as first property. Alias of the container.
  type: string # Type of the registry like ACR or GCR.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  trigger: trigger | none | true # Specify none to disable, true to trigger on all image tags, or use the full syntax as described in the following examples.
  azureSubscription: string # Azure subscription (ARM service connection) for container registry.
  resourceGroup: string # Resource group for your ACR.
  registry: string # Registry for container images.
  repository: string # Name of the container image repository in ACR.
  localImage: boolean # When true, uses a locally tagged image instead of using docker pull to get the image. The default is false.

引用此定义的定义:resources.containers

性能

container 字符串。 必需为第一个属性。
容器的 ID。 可接受的值:[-_A-Za-z0-9]*。

image 字符串。 必填。
容器映像标记。

type 字符串。
ACR 或 GCR 等注册表的类型。

trigger resources.containers.container.trigger
指定“不禁用”、“true”在所有图像标记上触发,或使用以下示例中所述的完整语法。

endpoint 字符串。
连接到专用容器注册表的服务终结点 ID。 支持模板表达式。

endpoint 字符串。
连接到专用容器注册表的服务终结点 ID。

env 字符串字典。
变量映射到容器的环境。

mapDockerSocket 布尔
将此标志设置为 false 以强制代理不要在容器作业上设置 /var/run/docker.sock 卷。

options 字符串。
要传入容器主机的选项。 支持模板表达式。

options 字符串。
要传入容器主机的选项。

ports 字符串列表。
要公开在容器上的端口。 支持模板表达式。

ports 字符串列表。
要公开在容器上的端口。

volumes 字符串列表。
要装载到容器上的卷。 支持模板表达式。

volumes 字符串列表。
要装载到容器上的卷。

mountReadOnly mountReadOnly
卷装载只读,默认值为 false。

azureSubscription 字符串。
容器注册表的 Azure 订阅(ARM 服务连接)。

resourceGroup 字符串。
ACR 的资源组。

registry 字符串。
容器映像的注册表。

repository 字符串。
ACR 中容器映像存储库的名称。

localImage 布尔
如果为 true,请使用本地标记的映像而不是使用 docker 拉取来获取映像。 默认值为 false。

此属性仅适用于代理计算机上已存在映像的自承载代理。

注解

容器作业 让你隔离容器内的工具和依赖项。

代理启动指定容器的实例,然后运行其中的步骤。 使用 container 关键字可以指定容器映像。

服务容器 与作业一起运行,以提供各种依赖项,例如数据库。

YAML 管道中容器资源的 endpointvolumesportsoptions 属性支持 模板表达式

例子

resources:
  containers:
  - container: linux
    image: ubuntu:16.04
  - container: windows
    image: myprivate.azurecr.io/windowsservercore:1803
    endpoint: my_acr_connection
  - container: my_service
    image: my_service:tag
    ports:
    - 8080:80 # bind container port 80 to 8080 on the host machine
    - 6379 # bind container port 6379 to a random available port on the host machine
    volumes:
    - /src/dir:/dst/dir # mount /src/dir on the host into /dst/dir in the container

另请参阅

在 YAML 中定义资源