コンテナー ジョブを使用すると、エージェント ホストではなくコンテナーでジョブを実行できます。
この定義を参照する定義: パイプライン、jobs.job、jobs.deployment
実装
| 実装 | 説明 | 
|---|---|
| コンテナー: 文字列 | エイリアスでジョブ コンテナーを指定します。 | 
| コンテナー: イメージ | イメージ タグとオプションを使用してジョブ コンテナーを指定します。 | 
container: string
エイリアスでジョブ コンテナーを指定します。
container: string # Specify job container by alias.
              container 文字列。
エイリアスでジョブ コンテナーを指定します。
注釈
エイリアスには、イメージの名前を指定することも、コンテナー リソースへの参照にすることもできます。
例示
次の例では、Docker Hub から 18.04 というタグが付いた ubuntu イメージ フェッチし、コンテナーを開始します。 
              printenv コマンドを実行すると、ubuntu:18.04 コンテナー内で実行されます。
pool:
  vmImage: 'ubuntu-18.04'
container: ubuntu:18.04
steps:
- script: printenv
container: image
イメージ タグとオプションを使用してジョブ コンテナーを指定します。
container:
  image: string # Required. Container image tag.
  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.
特性
              image 文字列。 必須。
コンテナー イメージ タグを  します。
              endpoint 文字列。
プライベート コンテナー レジストリに接続するサービス エンドポイントの  ID。
文字列ディクショナリ env します。
               変数を使用して、コンテナーの環境にマップします。
ブールを mapDockerSocketします。
               コンテナー ジョブで /var/run/docker.sock ボリュームをセットアップしないようにエージェントに強制するには、このフラグを false に設定します。
              options 文字列。
               コンテナー ホストに渡すオプション。
文字列リスト ports します。
コンテナーで公開するポートを  します。
文字列リスト volumes します。
コンテナーにマウントするボリュームを  します。
mountReadOnlyを mountReadOnlyします。
読み取り専用をマウントするボリューム 、既定値はすべて false です。
container: image
イメージ タグとオプションを使用してジョブ コンテナーを指定します。
container:
  image: string # Required. Container image tag.
  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.
特性
              image 文字列。 必須。
コンテナー イメージ タグを  します。
              endpoint 文字列。
プライベート コンテナー レジストリに接続するサービス エンドポイントの  ID。
文字列ディクショナリ env します。
               変数を使用して、コンテナーの環境にマップします。
ブールを mapDockerSocketします。
               コンテナー ジョブで /var/run/docker.sock ボリュームをセットアップしないようにエージェントに強制するには、このフラグを false に設定します。
              options 文字列。
               コンテナー ホストに渡すオプション。
文字列リスト ports します。
コンテナーで公開するポートを  します。
文字列リスト volumes します。
コンテナーにマウントするボリュームを  します。
例示
              options を使用してコンテナーの起動を構成します。
container:
  image: ubuntu:18.04
  options: --hostname container-test --ip 192.168.0.1
steps:
- script: echo hello
次の例では、コンテナーは resources セクションで定義されています。 その後、各コンテナーは、割り当てられたエイリアスを参照して、後で参照されます。
resources:
  containers:
  - container: u14
    image: ubuntu:14.04
  - container: u16
    image: ubuntu:16.04
  - container: u18
    image: ubuntu:18.04
jobs:
- job: RunInContainer
  pool:
    vmImage: 'ubuntu-18.04'
  strategy:
    matrix:
      ubuntu14:
        containerResource: u14
      ubuntu16:
        containerResource: u16
      ubuntu18:
        containerResource: u18
  container: $[ variables['containerResource'] ]
  steps:
  - script: printenv