Docker イメージをビルド、タグ付け、プッシュ、または実行するか、Docker コマンドを実行します。 このタスクは、Docker または Azure Container Registry で使用します。
注
Docker@2 は、このタスクの新しいバージョンであり、コマンドに引数として渡すことができる入力を削除することでタスクを簡略化します。
構文
# Docker v1
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@1
inputs:
# Container Registry
#containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when command != logout. Container registry type. Default: Azure Container Registry.
#dockerRegistryEndpoint: # string. Optional. Use when containerregistrytype = Container Registry && command != logout. Docker registry service connection.
#azureSubscriptionEndpoint: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure subscription.
#azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure container registry.
# Commands
#addBaseImageData: true # boolean. Add base image metadata to image(s). Default: true.
command: 'Build an image' # 'Build an image' | 'Tag image' | 'Push an image' | 'Run an image' | 'login' | 'logout'. Required. Command. Default: Build an image.
#dockerFile: '**/Dockerfile' # string. Required when command = Build an image || command = build. Dockerfile. Default: **/Dockerfile.
#arguments: # string. Optional. Use when command != login && command != logout. Arguments.
#pushMultipleImages: false # boolean. Optional. Use when command = Push an image || command = push. Push multiple images. Default: false.
#tagMultipleImages: false # boolean. Optional. Use when command = Tag image || command = tag. Tag multiple images. Default: false.
#imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when command = Build an image || command = build || command = Run an image || command = run || pushMultipleImages = false || tagMultipleImages = false. Image name. Default: $(Build.Repository.Name):$(Build.BuildId).
#imageNamesPath: # string. Required when tagMultipleImages = true || pushMultipleImages = true. Image names path.
#qualifyImageName: true # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push || command = Run an image || command = run. Qualify image name. Default: true.
#qualifySourceImageName: false # boolean. Optional. Use when command = Tag image || command = tag. Qualify source image name. Default: false.
#includeSourceTags: false # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push. Include source tags. Default: false.
#includeLatestTag: false # boolean. Optional. Use when command = Build an image || command = build. Include latest tag. Default: false.
#addDefaultLabels: true # boolean. Optional. Use when addDefaultLabels = false. Add default labels. Default: true.
#useDefaultContext: true # boolean. Optional. Use when command = Build an image || command = build. Use default build context. Default: true.
#buildContext: # string. Optional. Use when useDefaultContext = false. Build context.
#imageDigestFile: # string. Optional. Use when command = Push an image || command = push. Image digest file.
#containerName: # string. Optional. Use when command = Run an image || command = run. Container name.
#ports: # string. Optional. Use when command = Run an image || command = run. Ports.
#volumes: # string. Optional. Use when command = Run an image || command = run. Volumes.
#envVars: # string. Optional. Use when command = Run an image || command = run. Environment variables.
#workingDirectory: # string. Optional. Use when command = Run an image || command = run. Working directory.
#entrypointOverride: # string. Optional. Use when command = Run an image || command = run. Entry point override.
#containerCommand: # string. Optional. Use when command = Run an image || command = run. Container command.
#runInBackground: true # boolean. Optional. Use when command = Run an image || command = run. Run in background. Default: true.
restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when runInBackground = true. Restart policy. Default: no.
#maxRestartRetries: # string. Optional. Use when runInBackground = true && restartPolicy = onFailure. Maximum restart retries.
# Advanced Options
#dockerHostEndpoint: # string. Optional. Use when command != login && command != logout. Docker host service connection.
#enforceDockerNamingConvention: true # boolean. Optional. Use when command != login && command != logout. Force image name to follow Docker naming convention. Default: true.
#memoryLimit: # string. Optional. Use when command != login && command != logout. Memory limit.
# Docker v1
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@1
inputs:
# Container Registry
#containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when command != logout. Container registry type. Default: Azure Container Registry.
#dockerRegistryEndpoint: # string. Optional. Use when containerregistrytype = Container Registry && command != logout. Docker registry service connection.
#azureSubscriptionEndpoint: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure subscription.
#azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure container registry.
# Commands
command: 'Build an image' # 'Build an image' | 'Tag image' | 'Push an image' | 'Run an image' | 'login' | 'logout'. Required. Command. Default: Build an image.
#dockerFile: '**/Dockerfile' # string. Required when command = Build an image || command = build. Dockerfile. Default: **/Dockerfile.
#arguments: # string. Optional. Use when command != login && command != logout. Arguments.
#pushMultipleImages: false # boolean. Optional. Use when command = Push an image || command = push. Push multiple images. Default: false.
#tagMultipleImages: false # boolean. Optional. Use when command = Tag image || command = tag. Tag multiple images. Default: false.
#imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when command = Build an image || command = build || command = Run an image || command = run || pushMultipleImages = false || tagMultipleImages = false. Image name. Default: $(Build.Repository.Name):$(Build.BuildId).
#imageNamesPath: # string. Required when tagMultipleImages = true || pushMultipleImages = true. Image names path.
#qualifyImageName: true # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push || command = Run an image || command = run. Qualify image name. Default: true.
#qualifySourceImageName: false # boolean. Optional. Use when command = Tag image || command = tag. Qualify source image name. Default: false.
#includeSourceTags: false # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push. Include source tags. Default: false.
#includeLatestTag: false # boolean. Optional. Use when command = Build an image || command = build. Include latest tag. Default: false.
#addDefaultLabels: true # boolean. Optional. Use when addDefaultLabels = false. Add default labels. Default: true.
#useDefaultContext: true # boolean. Optional. Use when command = Build an image || command = build. Use default build context. Default: true.
#buildContext: # string. Optional. Use when useDefaultContext = false. Build context.
#imageDigestFile: # string. Optional. Use when command = Push an image || command = push. Image digest file.
#containerName: # string. Optional. Use when command = Run an image || command = run. Container name.
#ports: # string. Optional. Use when command = Run an image || command = run. Ports.
#volumes: # string. Optional. Use when command = Run an image || command = run. Volumes.
#envVars: # string. Optional. Use when command = Run an image || command = run. Environment variables.
#workingDirectory: # string. Optional. Use when command = Run an image || command = run. Working directory.
#entrypointOverride: # string. Optional. Use when command = Run an image || command = run. Entry point override.
#containerCommand: # string. Optional. Use when command = Run an image || command = run. Container command.
#runInBackground: true # boolean. Optional. Use when command = Run an image || command = run. Run in background. Default: true.
restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when runInBackground = true. Restart policy. Default: no.
#maxRestartRetries: # string. Optional. Use when runInBackground = true && restartPolicy = onFailure. Maximum restart retries.
# Advanced Options
#dockerHostEndpoint: # string. Optional. Use when command != login && command != logout. Docker host service connection.
#enforceDockerNamingConvention: true # boolean. Optional. Use when command != login && command != logout. Force image name to follow Docker naming convention. Default: true.
#memoryLimit: # string. Optional. Use when command != login && command != logout. Memory limit.
入力
containerregistrytype
-
コンテナー レジストリの種類
string。
command != logoutする場合に必要です。 使用できる値: Azure Container Registry、Container Registry。 既定値: Azure Container Registry.
Azure サービス接続を使用して接続する Azure Container Registry を指定します。 Docker Hub またはその他のプライベート コンテナー レジストリに接続する Azure Container Registry を選択します。
addBaseImageData
-
イメージに基本イメージ メタデータを追加する
boolean。 既定値: true.
既定値は、追跡可能性に役立つ基本イメージの名前やダイジェストなどの基本イメージ データを追加します。 この既定の動作を無効にするには、この値を falseに設定します。
Docker レジストリ サービス接続を dockerRegistryEndpoint - する
string。 任意
containerregistrytype = Container Registry && command != logoutするときに使用します。
Docker レジストリ サービス接続を指定します。 レジストリを使用して認証するコマンドに必要です。
Azure サブスクリプション を
string。 任意
containerregistrytype = Azure Container Registry && command != logoutするときに使用します。
Azure サブスクリプションを指定します。
Azure コンテナー レジストリの azureContainerRegistry -
string。 任意
containerregistrytype = Azure Container Registry && command != logoutするときに使用します。
選択した Azure サブスクリプションの Azure Container Registry を指定します。 コンテナー イメージがビルドされ、このコンテナー レジストリにプッシュされます。
command
-
コマンド
string。 必須。 使用できる値: Build an image (ビルド)、Tag image (タグ)、Push an image (プッシュ)、Run an image (実行)、login、logout。 既定値: Build an image.
実行する docker コマンドを指定します。
Dockerfileを dockerFile - する
string。
command = Build an image || command = buildする場合に必要です。 既定値: **/Dockerfile.
Docker ファイルへのパスを指定します。 タスクは、検出された最初の Docker ファイルを使用してイメージをビルドします。
arguments
-
引数
string。 任意
command != login && command != logoutするときに使用します。
Docker クライアントに渡す追加の引数を指定します。 コマンド パラメーターで buildAndPush 値を使用すると、arguments プロパティは無視されます。
pushMultipleImages
-
複数のイメージをプッシュ
boolean。 任意
command = Push an image || command = pushするときに使用します。 既定値: false.
プッシュする Docker イメージのテキスト ファイル内のリストを指定します。 各イメージ名を、Imagename1:tag1 形式で個別の行に一覧表示します。
Imagename2など、タグのないイメージ名を一覧表示すると、Imagename2 コンテナー内のすべてのタグがプッシュされます。
tagMultipleImages
-
複数の画像にタグを付
boolean。 任意
command = Tag image || command = tagするときに使用します。 既定値: false.
テキスト ファイルにタグを付ける複数のイメージ タグと Docker イメージの一覧を指定します。 各イメージ名を、Imagename1:tag1 形式で個別の行に一覧表示します。 タグなしで Imagename2 として一覧表示された画像は、既定で最新 タグ付けされます。
imageName
-
イメージ名の
string。
command = Build an image || command = build || command = Run an image || command = run || pushMultipleImages = false || tagMultipleImages = falseする場合に必要です。 既定値: $(Build.Repository.Name):$(Build.BuildId).
ビルド、プッシュ、または実行する Docker イメージの名前を指定します。
imageNamesPath
-
イメージ名のパス
string。
tagMultipleImages = true || pushMultipleImages = trueする場合に必要です。
タグ付けまたはプッシュする Docker イメージの名前を含むテキスト ファイルへのパスを指定します。 各イメージ名を個別の行に一覧表示します。
qualifyImageName
-
イメージ名の を修飾する
boolean。 任意
command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push || command = Run an image || command = runするときに使用します。 既定値: true.
Docker レジストリ サービス接続のホスト名で修飾イメージ名を指定します。
qualifySourceImageName
-
ソース イメージ名の を修飾する
boolean。 任意
command = Tag image || command = tagするときに使用します。 既定値: false.
Docker レジストリ サービス接続のホスト名で修飾イメージ名を指定します。
includeSourceTags
-
ソース タグの を含める
boolean。 任意
command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = pushするときに使用します。 既定値: false.
Docker イメージをビルドまたはプッシュするときに含める Git タグを指定します。
includeLatestTag
-
最新のタグ を含める
boolean。 任意
command = Build an image || command = buildするときに使用します。 既定値: false.
Docker イメージをビルドするときに、最新の タグを使用するかどうかを指定します。
addDefaultLabels
-
既定のラベル を追加する
boolean。 任意
addDefaultLabels = falseするときに使用します。 既定値: true.
リポジトリ、コミット、ビルド、リリース情報などの Docker ラベルを使用して、コンテナー イメージに CI/CD メタデータを追加するかどうかを指定します。
useDefaultContext
-
既定のビルド コンテキスト を使用する
boolean。 任意
command = Build an image || command = buildするときに使用します。 既定値: true.
Docker ファイルを含むディレクトリへのビルド コンテキストの追加または削除を指定します。
ビルド コンテキストの buildContext -
string。 任意
useDefaultContext = falseするときに使用します。
ビルド コンテキストへのパスを指定します。
imageDigestFile
-
イメージ ダイジェスト ファイルの
string。 任意
command = Push an image || command = pushするときに使用します。
プッシュされた Docker イメージの完全なイメージ リポジトリ ダイジェストが作成され、設定されるファイルへのパスを指定します。
containerName
-
コンテナー名の
string。 任意
command = Run an image || command = runするときに使用します。
実行する Docker コンテナーの名前を指定します。
ports
-
ポートの
string。 任意
command = Run an image || command = runするときに使用します。
ホストに発行する Docker コンテナー内のポートを指定します。 各 host-port:container-port バインドを個別の行に一覧表示します。
ボリュームの volumes -
string。 任意
command = Run an image || command = runするときに使用します。
ホストからマウントするボリュームを指定します。 各 host-dir:container-dir を個別の行に一覧表示します。
envVars
-
環境変数
string。 任意
command = Run an image || command = runするときに使用します。
Docker コンテナーの環境変数を指定します。 各 name=value ペアを個別の行に一覧表示します。
workingDirectory
-
作業ディレクトリの
string。 任意
command = Run an image || command = runするときに使用します。
Docker コンテナーの作業ディレクトリを指定します。
entrypointOverride
-
エントリ ポイントのオーバーライド
string。 任意
command = Run an image || command = runするときに使用します。
Docker コンテナーの既定のエントリ ポイントをオーバーライドするかどうかを指定します。
containerCommand
-
Container コマンド
string。 任意
command = Run an image || command = runするときに使用します。
Docker 実行コマンドを指定します。 docker run コマンドは、最初に、指定したイメージに書き込み可能なコンテナー レイヤーを作成し、指定した run コマンドを使用して開始します。 たとえば、イメージに単純な Python Flask Web アプリケーションが含まれている場合は、Web アプリケーションを起動する python app.py を指定できます。
runInBackground
-
バックグラウンドで実行
boolean。 任意
command = Run an image || command = runするときに使用します。 既定値: true.
Docker コンテナーをバックグラウンドで実行するかどうかを指定します。
restartPolicy
-
再起動ポリシー
string。
runInBackground = trueする場合に必要です。 使用できる値: no、onFailure (エラー時)、always、unlessStopped (停止しない限り)。 既定値: no.
再起動ポリシーを実行するタイミングを指定します。
maxRestartRetries
-
再起動の最大再試行回数
string。 任意
runInBackground = true && restartPolicy = onFailureするときに使用します。
Docker デーモンが試行する再起動再試行の最大数を指定します。
Docker ホスト サービス接続を dockerHostEndpoint - する
string。 任意
command != login && command != logoutするときに使用します。
Docker ホスト サービス接続を指定します。 既定では、エージェントのホストが使用されます。
enforceDockerNamingConvention
-
Docker の名前付け規則に従うようにイメージ名を強制する
boolean。 任意
command != login && command != logoutするときに使用します。 既定値: true.
既定値は、Docker の名前付け規則に従って Docker イメージ名を変更します。 たとえば、大文字を小文字に変換し、スペースを削除します。
memoryLimit
-
メモリ制限の
string。 任意
command != login && command != logoutするときに使用します。
コンテナーで使用できるメモリの最大量を整数として指定し、省略可能なサフィックス (2GBなど) を指定します。
タスク コントロールのオプション
すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「コントロール オプションと一般的なタスク プロパティを参照してください。
出力変数
このタスクでは、次の 出力変数を定義します。この変数は、ダウンストリームのステップ、ジョブ、およびステージで使用できます。
DockerOutput
docker コマンドの出力を格納します
DockerOutputPath
ビルド コマンドの出力を含むファイルのパス。
このタスクでは、次の 出力変数を定義します。この変数は、ダウンストリームのステップ、ジョブ、およびステージで使用できます。
DockerOutput
docker コマンドの出力を格納します
注釈
Docker@2 は、このタスクの新しいバージョンであり、コマンドに引数として渡すことができる入力を削除することでタスクを簡略化します。
必要条件
| 要件 | 説明 |
|---|---|
| パイプラインの種類 | YAML、クラシック ビルド、クラシック リリース |
| 実行日 | エージェント、DeploymentGroup |
| の需要 | なし |
| 機能の | このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。 |
| コマンドの制限 | どれでも |
| 設定可能な変数 | どれでも |
| エージェントのバージョン | サポートされているすべてのエージェント バージョン。 |
| タスク カテゴリ | 建築する |