რედაქტირება

გაზიარება არხიდან:


Docker@0 - Docker v0 task

Build, tag, push, run Docker images, or run a Docker command. Use this task with Docker or the Azure Container registry.

Note

Docker@2 is a newer version of this task that simplifies the task by removing inputs that can be passed as arguments to the command.

Build, tag, push, run Docker images, or run a Docker command. Use this task with Docker or the Azure Container registry.

Note

Docker@2 is a newer version of this task that simplifies the task by removing inputs that can be passed as arguments to the command.

Syntax

# 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.
# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command. Task can be used with Docker or Azure Container registry.
- 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.

Inputs

containerregistrytype - Container Registry Type
string. Required. Allowed values: Azure Container Registry, Container Registry. Default value: Azure Container Registry.

Select 'Azure Container Registry' to connect to it by using an Azure Service Connection. Select 'Container registry' to connect to Docker Hub or any other private container registry.


dockerRegistryConnection - Docker Registry Service Connection
Input alias: dockerRegistryEndpoint. string. Optional. Use when containerregistrytype = Container Registry.

Specifies a Docker registry service connection. Required for commands that need to authenticate with a registry.


azureSubscription - Azure subscription
Input alias: azureSubscriptionEndpoint. string. Optional. Use when containerregistrytype = Azure Container Registry.

Specifies an Azure subscription.


azureContainerRegistry - Azure Container Registry
string. Optional. Use when containerregistrytype = Azure Container Registry.

Specifies an Azure Container Registry in the selected Azure Subscription. The container image is built and then pushed to this container registry.


action - Action
string. Required. Allowed values: Build an image, Tag images, Push an image, Push images, Run an image, Run a Docker command. Default value: Build an image.

Specifies a Docker action.


dockerFile - Docker File
string. Required when action = Build an image. Default value: **/Dockerfile.

Specifies the path to the Docker file. The task uses the first Docker file it finds to build the image.


addBaseImageData - Add base image metadata to image(s)
boolean. Default value: true.

The default value adds base image data such as, the base image name and digest to help with traceability. You can opt out by setting the value to false.


buildArguments - Build Arguments
string. Optional. Use when action = Build an image.

Specifies build-time variables for the Docker file. Format each name=value pair on a new line.


defaultContext - Use Default Build Context
boolean. Optional. Use when action = Build an image. Default value: true.

Specifies the build context of the directory that contains the Docker file.


context - Build Context
string. Optional. Use when action = Build an image && defaultContext = false.

Specifies the path to the build context.


imageName - Image Name
string. Required when action == Build an image || action == Push an image || action == Run an image. Default value: $(Build.Repository.Name):$(Build.BuildId).

Specifies the name of the Docker image to build, push, or run.


imageNamesPath - Image Names Path
string. Required when action == Tag images || action == Push images.

Specifies the path to a text file that contains the names of the Docker images to tag or push. List each image name on a separate line.


qualifyImageName - Qualify Image Name
boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Default value: true.

Specifies a qualify image name with the Docker registry service connection's hostname.


additionalImageTags - Additional Image Tags
string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images.

Specifies additional tags for the Docker image being built or pushed.


includeSourceTags - Include Source Tags
boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Default value: false.

Specifies whether to include Git tags when building or pushing the Docker image.


includeLatestTag - Include Latest Tag
boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Default value: false.

Specifies whether to include the latest tag when building or pushing the Docker image.


imageDigestFile - Image Digest File
string. Optional. Use when action = Push an image || action = Push images.

Specifies the path to a file that is created and populated with the full image repository digest of the Docker image that was pushed.


containerName - Container Name
string. Optional. Use when action = Run an image.

Specifies the name of the Docker container to run.


ports - Ports
string. Optional. Use when action = Run an image.

Specifies ports in the Docker container to publish to the host. List each host-port:container-port binding on a new line.


volumes - Volumes
string. Optional. Use when action = Run an image.

Specifies the volumes to mount from the host. List each host-dir:container-dir on a new line.


envVars - Environment Variables
string. Optional. Use when action = Run an image.

Specifies environment variables for the Docker container. List each name=value pair on a new line.


workDir - Working Directory
string. Optional. Use when action = Run an image.

Specifies the working directory for the Docker container.


entrypoint - Entry Point Override
string. Optional. Use when action = Run an image.

Specifies an override of the default entry point for the Docker container.


containerCommand - Command
string. Optional. Use when action = Run an image.

Specifies a Docker run command. The docker run command first creates a writeable container layer over the specified image, and then starts it by using the specified run command. For example, if the image contains a simple Python Flask web application you can specify python app.py to launch the web application.


detached - Run In Background
boolean. Optional. Use when action = Run an image. Default value: true.

Specifies whether to run the Docker container in the background.


restartPolicy - Restart Policy
string. Required when action = Run an image && detached = true. Allowed values: no, onFailure (On failure), always, unlessStopped (Unless stopped). Default value: no.

Specifies a restart policy.


restartMaxRetries - Maximum Restart Retries
string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure.

Specifies the maximum number of restart retries that the Docker daemon attempts.


customCommand - Command
string. Required when action = Run a Docker command.

Specifies the Docker command and arguments to execute. For example, rmi -f image-name removes an image.


dockerHostEndpoint - Docker Host Service Connection
string.

Specifies a Docker host service connection. Defaults to the agent's host.


enforceDockerNamingConvention - Force image name to follow Docker naming convention
boolean. Default value: true.

If enabled, modifies the Docker image name according to Docker naming conventions. For example, convert upper case characters to lower case and remove spaces.


workingDirectory - Working Directory
Input alias: cwd. string. Default value: $(System.DefaultWorkingDirectory).

Specifies the working directory for the Docker command.


memory - Memory limit
string.

Specifies the maximum amount of memory available to the container as a integer with optional suffixes, for example 2GB.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

This task defines the following output variables, which you can consume in downstream steps, jobs, and stages.

DockerOutput
Stores the output of the docker command.

DockerOutputPath
The path of the file which contains the output of the build command.

This task defines the following output variables, which you can consume in downstream steps, jobs, and stages.

DockerOutput
Stores the output of the docker command

Remarks

Docker@2 is a newer version of this task that simplifies the task by removing inputs that can be passed as arguments to the command.

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version All supported agent versions.
Task category Build

See also