resources.containers.container definition

容器資源會參考容器映射。

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.
containers:
- container: string # Required as first property. Alias of the container.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  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。

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

endpoint 字串。
連線到私人容器登錄的服務端點識別碼。 支援範本運算式

endpoint 字串。
連線到私人容器登錄的服務端點識別碼。

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

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

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

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

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

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

volumes 字串清單。
要掛接在容器上的磁片區。 支援範本運算式

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

mountReadOnlymountReadOnly
要掛接唯讀的磁片區,預設值為 false。

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

resourceGroup 字串。
ACR 的資源群組。

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

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

localImage布林值
若為 true,請使用本機標記的映射,而不是使用 docker 提取來取得映射。 預設值為 false。

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

備註

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

代理程式會啟動您指定的容器執行個體,然後執行其中的步驟。 關鍵字 container 可讓您指定容器映射。

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

YAML 管線中容器資源的 、 portsvolumesoptions 屬性都支援 endpoint範本運算式

範例

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