共用方式為


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.
  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.
  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.
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.

參考此定義的定義:resources.containers

性能

container 字串。 做為第一個屬性的必要屬性。
容器的標識碼。 可接受的值:[-_A-Za-z0-9]*。

image 字串。 必須的。
容器映像標記。

type 字串。
ACR 或 GCR 之類的登錄類型。

trigger resources.containers.container.trigger
指定無停用、true 以在所有影像標記上觸發,或使用如下列範例中所述的完整語法。

azureSubscription 字串。
容器登錄的 Azure 訂用帳戶(ARM 服務連線)。

resourceGroup 字串。
ACR 的資源群組。

registry 字串。
容器映像的登錄。

repository 字串。
ACR 中容器映像存放庫的名稱。

localImage 布林值
若為 true,請使用本機標記的映射,而不是使用 docker pull 來取得映像。 默認值為 false。

此屬性僅適用於代理程式電腦上已存在映像的自我裝載代理程式。

endpoint 字串。
連線至私人容器登錄的服務端點標識符。 支援範本表示式。

endpoint 字串。
連線至私人容器登錄的服務端點標識符。

env 字串字典。
變數,以對應至容器的環境。

mapDockerSocket 布林值
將此旗標設定為 false,強制代理程式不要在容器作業上設定 /var/run/docker.sock 磁碟區。

options 字串。
要傳遞至容器主機的選項。 支援範本表示式。

options 字串。
要傳遞至容器主機的選項。

ports 字串清單。
要公開在容器上的埠。 支援範本表示式。

ports 字串清單。
要公開在容器上的埠。

volumes 字串清單。
要掛接在容器上的磁碟區。 支援範本表示式。

volumes 字串清單。
要掛接在容器上的磁碟區。

mountReadOnly mountReadOnly
磁碟區掛接只讀,預設值為 false。

備註

容器作業 可讓您隔離容器內的工具和相依性。

代理程式會啟動您指定容器的實例,然後在其中執行步驟。 container 關鍵詞可讓您指定容器映像。

服務容器 與作業一起執行,以提供各種相依性,例如資料庫。

YAML 管線中容器資源的 endpointvolumesports 屬性支援 options

範例

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 中定義資源