次の方法で共有


Docker@0 - Docker v0 タスク

Docker イメージのビルド、タグ付け、プッシュ、実行、または Docker コマンドの実行。 このタスクは、Docker または Azure Container Registry で使用します。

Docker@2 は、このタスクの新しいバージョンであり、コマンドに引数として渡すことができる入力を削除することでタスクを簡略化します。

Docker イメージのビルド、タグ付け、プッシュ、実行、または Docker コマンドの実行。 このタスクは、Docker または Azure Container Registry で使用します。

Docker@2 は、このタスクの新しいバージョンであり、コマンドに引数として渡すことができる入力を削除することでタスクを簡略化します。

構文

# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@0
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. Optional. Use when containerregistrytype = Container Registry. Docker Registry Service Connection. 
    #azureSubscription: # string. Alias: azureSubscriptionEndpoint. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure Container Registry. 
    action: 'Build an image' # 'Build an image' | 'Tag images' | 'Push an image' | 'Push images' | 'Run an image' | 'Run a Docker command'. Required. Action. Default: Build an image.
    #dockerFile: '**/Dockerfile' # string. Required when action = Build an image. Docker File. Default: **/Dockerfile.
    #buildArguments: # string. Optional. Use when action = Build an image. Build Arguments. 
    #defaultContext: true # boolean. Optional. Use when action = Build an image. Use Default Build Context. Default: true.
    #context: # string. Optional. Use when action = Build an image && defaultContext = false. Build Context. 
    #imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when action == Build an image || action == Push an image || action == Run an image. Image Name. Default: $(Build.Repository.Name):$(Build.BuildId).
    #imageNamesPath: # string. Required when action == Tag images || action == Push images. Image Names Path. 
    #qualifyImageName: true # boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Qualify Image Name. Default: true.
    #additionalImageTags: # string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Include Latest Tag. Default: false.
    #imageDigestFile: # string. Optional. Use when action = Push an image || action = Push images. Image Digest File. 
    #containerName: # string. Optional. Use when action = Run an image. Container Name. 
    #ports: # string. Optional. Use when action = Run an image. Ports. 
    #volumes: # string. Optional. Use when action = Run an image. Volumes. 
    #envVars: # string. Optional. Use when action = Run an image. Environment Variables. 
    #workDir: # string. Optional. Use when action = Run an image. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run an image. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run an image. Command. 
    #detached: true # boolean. Optional. Use when action = Run an image. Run In Background. Default: true.
    #restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when action = Run an image && detached = true. Restart Policy. Default: no.
    #restartMaxRetries: # string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure. Maximum Restart Retries. 
    #customCommand: # string. Required when action = Run a Docker command. Command. 
  # commands
    #addBaseImageData: true # boolean. Add base image metadata to image(s). Default: true.
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #enforceDockerNamingConvention: true # boolean. Force image name to follow Docker naming convention. Default: true.
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #memory: # string. Memory limit.
# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@0
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. Optional. Use when containerregistrytype = Container Registry. Docker Registry Service Connection. 
    #azureSubscription: # string. Alias: azureSubscriptionEndpoint. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure Container Registry. 
    action: 'Build an image' # 'Build an image' | 'Tag images' | 'Push an image' | 'Push images' | 'Run an image' | 'Run a Docker command'. Required. Action. Default: Build an image.
    #dockerFile: '**/Dockerfile' # string. Required when action = Build an image. Docker File. Default: **/Dockerfile.
    #buildArguments: # string. Optional. Use when action = Build an image. Build Arguments. 
    #defaultContext: true # boolean. Optional. Use when action = Build an image. Use Default Build Context. Default: true.
    #context: # string. Optional. Use when action = Build an image && defaultContext = false. Build Context. 
    #imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when action == Build an image || action == Push an image || action == Run an image. Image Name. Default: $(Build.Repository.Name):$(Build.BuildId).
    #imageNamesPath: # string. Required when action == Tag images || action == Push images. Image Names Path. 
    #qualifyImageName: true # boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Qualify Image Name. Default: true.
    #additionalImageTags: # string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Include Latest Tag. Default: false.
    #imageDigestFile: # string. Optional. Use when action = Push an image || action = Push images. Image Digest File. 
    #containerName: # string. Optional. Use when action = Run an image. Container Name. 
    #ports: # string. Optional. Use when action = Run an image. Ports. 
    #volumes: # string. Optional. Use when action = Run an image. Volumes. 
    #envVars: # string. Optional. Use when action = Run an image. Environment Variables. 
    #workDir: # string. Optional. Use when action = Run an image. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run an image. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run an image. Command. 
    #detached: true # boolean. Optional. Use when action = Run an image. Run In Background. Default: true.
    #restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when action = Run an image && detached = true. Restart Policy. Default: no.
    #restartMaxRetries: # string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure. Maximum Restart Retries. 
    #customCommand: # string. Required when action = Run a Docker command. Command. 
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #enforceDockerNamingConvention: true # boolean. Force image name to follow Docker naming convention. Default: true.
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #memory: # string. Memory limit.

入力

containerregistrytype - コンテナー レジストリの種類の
string。 必須。 使用できる値: Azure Container RegistryContainer Registry。 既定値: Azure Container Registry.

Azure サービス接続を使用して接続するには、[Azure Container Registry] を選択します。 [コンテナー レジストリ] を選択して、Docker Hub またはその他のプライベート コンテナー レジストリに接続します。


Docker レジストリ サービス接続dockerRegistryConnection -
入力エイリアス: dockerRegistryEndpointstring。 任意 containerregistrytype = Container Registryするときに使用します。

Docker レジストリ サービス接続を指定します。 レジストリで認証する必要があるコマンドに必要です。


Azure サブスクリプション を する
入力エイリアス: azureSubscriptionEndpointstring。 任意 containerregistrytype = Azure Container Registryするときに使用します。

Azure サブスクリプションを指定します。


Azure Container Registry を する
string。 任意 containerregistrytype = Azure Container Registryするときに使用します。

選択した Azure サブスクリプションの Azure Container Registry を指定します。 コンテナー イメージがビルドされ、このコンテナー レジストリにプッシュされます。


action - アクションの
string。 必須。 使用できる値: Build an imageTag imagesPush an imagePush imagesRun an imageRun a Docker command。 既定値: Build an image.

Docker アクションを指定します。


Docker ファイルdockerFile - する
stringaction = Build an imageする場合に必要です。 既定値: **/Dockerfile.

Docker ファイルへのパスを指定します。 タスクでは、検出された最初の Docker ファイルを使用してイメージをビルドします。


addBaseImageData - イメージに基本イメージ メタデータを追加する
boolean。 既定値: true.

既定値は、基本イメージ名やダイジェストなどの基本イメージ データを追加して、追跡可能性に役立ちます。 この値を falseに設定することで、オプトアウトできます。


buildArguments - ビルド引数の
string。 任意 action = Build an imageするときに使用します。

Docker ファイルのビルド時変数を指定します。 各 name=value ペアを新しい行に書式設定します。


既定のビルド コンテキストを使用する defaultContext -
boolean。 任意 action = Build an imageするときに使用します。 既定値: true.

Docker ファイルを含むディレクトリのビルド コンテキストを指定します。


ビルド コンテキストcontext -
string。 任意 action = Build an image && defaultContext = falseするときに使用します。

ビルド コンテキストへのパスを指定します。


imageName - イメージ名の
stringaction == Build an image || action == Push an image || action == Run an imageする場合に必要です。 既定値: $(Build.Repository.Name):$(Build.BuildId).

ビルド、プッシュ、または実行する Docker イメージの名前を指定します。


imageNamesPath - イメージ名のパス
stringaction == Tag images || action == Push imagesする場合に必要です。

タグ付けまたはプッシュする Docker イメージの名前を含むテキスト ファイルへのパスを指定します。 各イメージ名を個別の行に一覧表示します。


イメージ名の修飾qualifyImageName -
boolean。 任意 action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an imageするときに使用します。 既定値: true.

Docker レジストリ サービス接続のホスト名で修飾イメージ名を指定します。


その他の画像タグadditionalImageTags - する
string。 任意 action = Build an image || action = Tag images || action = Push an image || action = Push imagesするときに使用します。

ビルドまたはプッシュされる Docker イメージの追加のタグを指定します。


ソース タグを含める includeSourceTags -
boolean。 任意 action = Build an image || action = Tag image || action = Push an image || action = Push imagesするときに使用します。 既定値: false.

Docker イメージをビルドまたはプッシュするときに Git タグを含めるかどうかを指定します。


最新のタグを含める includeLatestTag -
boolean。 任意 action = Build an image || action = Push an image || action = Push imagesするときに使用します。 既定値: false.

Docker イメージをビルドまたはプッシュするときに、最新の タグを含めるかどうかを指定します。


imageDigestFile - イメージ ダイジェスト ファイルの
string。 任意 action = Push an image || action = Push imagesするときに使用します。

プッシュされた Docker イメージの完全なイメージ リポジトリ ダイジェストが作成され、設定されるファイルへのパスを指定します。


containerName - コンテナー名の
string。 任意 action = Run an imageするときに使用します。

実行する Docker コンテナーの名前を指定します。


ports - ポートの
string。 任意 action = Run an imageするときに使用します。

ホストに発行する Docker コンテナー内のポートを指定します。 各 host-port:container-port バインドを新しい行に一覧表示します。


ボリュームvolumes -
string。 任意 action = Run an imageするときに使用します。

ホストからマウントするボリュームを指定します。 各 host-dir:container-dir を新しい行に一覧表示します。


envVars - 環境変数の
string。 任意 action = Run an imageするときに使用します。

Docker コンテナーの環境変数を指定します。 各 name=value ペアを新しい行に一覧表示します。


workDir - 作業ディレクトリの
string。 任意 action = Run an imageするときに使用します。

Docker コンテナーの作業ディレクトリを指定します。


entrypoint - エントリ ポイントのオーバーライド
string。 任意 action = Run an imageするときに使用します。

Docker コンテナーの既定のエントリ ポイントのオーバーライドを指定します。


containerCommand - コマンド
string。 任意 action = Run an imageするときに使用します。

Docker 実行コマンドを指定します。 docker run コマンドは、最初に、指定したイメージに書き込み可能なコンテナー レイヤーを作成し、指定した run コマンドを使用して開始します。 たとえば、イメージに単純な Python Flask Web アプリケーションが含まれている場合は、Web アプリケーションを起動する python app.py を指定できます。


バックグラウンドで実行 detached -
boolean。 任意 action = Run an imageするときに使用します。 既定値: true.

Docker コンテナーをバックグラウンドで実行するかどうかを指定します。


restartPolicy - 再起動ポリシー
stringaction = Run an image && detached = trueする場合に必要です。 使用できる値: noonFailure (エラー時)、alwaysunlessStopped (停止しない限り)。 既定値: no.

再起動ポリシーを指定します。


restartMaxRetries - 再起動の最大再試行回数
string。 任意 action = Run an image && detached = true && restartPolicy = onFailureするときに使用します。

Docker デーモンが試行する再起動再試行の最大数を指定します。


customCommand - コマンド
stringaction = Run a Docker commandする場合に必要です。

実行する Docker コマンドと引数を指定します。 たとえば、rmi -f image-name はイメージを削除します。


Docker ホスト サービス接続dockerHostEndpoint -
string

Docker ホスト サービス接続を指定します。 既定では、エージェントのホストが使用されます。


enforceDockerNamingConvention - Docker の名前付け規則に従うようにイメージ名を強制する
boolean。 既定値: true.

有効な場合は、Docker の名前付け規則に従って Docker イメージ名を変更します。 たとえば、大文字を小文字に変換し、スペースを削除します。


workingDirectory - 作業ディレクトリの
入力エイリアス: cwdstring。 既定値: $(System.DefaultWorkingDirectory).

Docker コマンドの作業ディレクトリを指定します。


memory - メモリ制限の
string

コンテナーで使用できるメモリの最大量を、省略可能なサフィックスを持つ整数として指定します (例: 2GB)。


タスク コントロールのオプション

すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「コントロール オプションと一般的なタスク プロパティを参照してください。

出力変数

このタスクでは、次の 出力変数を定義します。この変数は、ダウンストリームのステップ、ジョブ、およびステージで使用できます。

DockerOutput
docker コマンドの出力を格納します。

DockerOutputPath
ビルド コマンドの出力を含むファイルのパス。

このタスクでは、次の 出力変数を定義します。この変数は、ダウンストリームのステップ、ジョブ、およびステージで使用できます。

DockerOutput
docker コマンドの出力を格納します

注釈

Docker@2 は、このタスクの新しいバージョンであり、コマンドに引数として渡すことができる入力を削除することでタスクを簡略化します。

必要条件

要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント、DeploymentGroup
の需要 なし
機能の このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 どれでも
設定可能な変数 どれでも
エージェントのバージョン サポートされているすべてのエージェント バージョン。
タスク カテゴリ 建築する

こちらもご覧ください