Bearbeiten

Freigeben über


DockerCompose@1 - Docker Compose v1 task

Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.

Syntax

# Docker Compose v1
# Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.
- task: DockerCompose@1
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryEndpoint: # string. 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. 
    dockerComposeFile: '**/docker-compose.yml' # string. Required. Docker Compose File. Default: **/docker-compose.yml.
    #additionalDockerComposeFiles: # string. Additional Docker Compose Files. 
    #dockerComposeFileArgs: # string. Environment Variables. 
    #projectName: '$(Build.Repository.Name)' # string. Project Name. Default: $(Build.Repository.Name).
    #qualifyImageNames: true # boolean. Qualify Image Names. Default: true.
    action: 'Run a Docker Compose command' # 'Build services' | 'Push services' | 'Run services' | 'Run a specific service' | 'Lock services' | 'Write service image digests' | 'Combine configuration' | 'Run a Docker Compose command'. Required. Action. Default: Run a Docker Compose command.
    #additionalImageTags: # string. Optional. Use when action = Build services || action = Push services. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build services || action = Push services. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build services || action = Push services. Include Latest Tag. Default: false.
    #buildImages: true # boolean. Optional. Use when action = Run services. Build Images. Default: true.
    #serviceName: # string. Required when action = Run a specific service. Service Name. 
    #containerName: # string. Optional. Use when action = Run a specific service. Container Name. 
    #ports: # string. Optional. Use when action = Run a specific service. Ports. 
    #workingDirectory: # string. Alias: workDir. Optional. Use when action = Run a specific service. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run a specific service. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run a specific service. Command. 
    #detached: true # boolean. Optional. Use when action = Run services || action = Run a specific service. Run in Background. Default: true.
    #abortOnContainerExit: true # boolean. Optional. Use when action = Run services && detached == false. Abort on Container Exit. Default: true.
    #imageDigestComposeFile: '$(Build.StagingDirectory)/docker-compose.images.yml' # string. Required when action = Write service image digests. Image Digest Compose File. Default: $(Build.StagingDirectory)/docker-compose.images.yml.
    #removeBuildOptions: false # boolean. Optional. Use when action = Lock services || action = Combine configuration. Remove Build Options. Default: false.
    #baseResolveDirectory: # string. Optional. Use when action = Lock services || action = Combine configuration. Base Resolve Directory. 
    #outputDockerComposeFile: '$(Build.StagingDirectory)/docker-compose.yml' # string. Required when action = Lock services || action = Combine configuration. Output Docker Compose File. Default: $(Build.StagingDirectory)/docker-compose.yml.
    #dockerComposeCommand: # string. Required when action = Run a Docker Compose command. Command. 
    #arguments: # string. Optional. Use when action != Lock services && action != Combine configuration && action != Write service image digests. Arguments. 
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #nopIfNoDockerComposeFile: false # boolean. No-op if no Docker Compose File. Default: false.
    #requireAdditionalDockerComposeFiles: false # boolean. Require Additional Docker Compose Files. Default: false.
    #currentWorkingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #dockerComposePath: # string. Docker Compose executable Path.

Inputs

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

Select a Container Registry Type.


dockerRegistryEndpoint - Docker Registry Service Connection
string. Optional. Use when containerregistrytype = Container Registry.

Select 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.

Select an Azure subscription.


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

Select an Azure Container Registry.


dockerComposeFile - Docker Compose File
string. Required. Default value: **/docker-compose.yml.

Path to the primary Docker Compose file to use.


additionalDockerComposeFiles - Additional Docker Compose Files
string.

Additional Docker Compose files to be combined with the primary Docker Compose file. Relative paths are resolved relative to the directory containing the primary Docker Compose file. If a specified file is not found, it is ignored. Specify each file path on a new line.


dockerComposeFileArgs - Environment Variables
string.

Environment variables to be set during the command. Specify each name=value pair on a new line.


projectName - Project Name
string. Default value: $(Build.Repository.Name).

Project name used for default naming of images and containers.


qualifyImageNames - Qualify Image Names
boolean. Default value: true.

Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified.


action - Action
string. Required. Allowed values: Build services (Build service images), Push services (Push service images), Run services (Run service images), Run a specific service (Run a specific service image), Lock services (Lock service images), Write service image digests, Combine configuration, Run a Docker Compose command. Default value: Run a Docker Compose command.

Select a Docker Compose action.


additionalImageTags - Additional Image Tags
string. Optional. Use when action = Build services || action = Push services.

Additional tags for the Docker images being built or pushed.


includeSourceTags - Include Source Tags
boolean. Optional. Use when action = Build services || action = Push services. Default value: false.

Include Git tags when building or pushing Docker images.


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

Include the 'latest' tag when building or pushing Docker images.


buildImages - Build Images
boolean. Optional. Use when action = Run services. Default value: true.

Build images before starting service containers.


serviceName - Service Name
string. Required when action = Run a specific service.

Name of the specific service to run.


containerName - Container Name
string. Optional. Use when action = Run a specific service.

Name of the specific service container to run.


ports - Ports
string. Optional. Use when action = Run a specific service.

Ports in the specific service container to publish to the host. Specify each host-port:container-port binding on a new line.


workingDirectory - Working Directory
Input alias: workDir. string. Optional. Use when action = Run a specific service.

The working directory for the specific service container.


entrypoint - Entry Point Override
string. Optional. Use when action = Run a specific service.

Override the default entry point for the specific service container.


containerCommand - Command
string. Optional. Use when action = Run a specific service.

Command to run in the specific service container. 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 services || action = Run a specific service. Default value: true.

Run the service containers in the background.


abortOnContainerExit - Abort on Container Exit
boolean. Optional. Use when action = Run services && detached == false. Default value: true.

Stop all containers when any container exits.


imageDigestComposeFile - Image Digest Compose File
string. Required when action = Write service image digests. Default value: $(Build.StagingDirectory)/docker-compose.images.yml.

Path to a Docker Compose file that is created and populated with the full image repository digests of each service's Docker image.


removeBuildOptions - Remove Build Options
boolean. Optional. Use when action = Lock services || action = Combine configuration. Default value: false.

Remove the build options from the output Docker Compose file.


baseResolveDirectory - Base Resolve Directory
string. Optional. Use when action = Lock services || action = Combine configuration.

The base directory from which relative paths in the output Docker Compose file should be resolved.


outputDockerComposeFile - Output Docker Compose File
string. Required when action = Lock services || action = Combine configuration. Default value: $(Build.StagingDirectory)/docker-compose.yml.

Path to an output Docker Compose file.


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

Docker Compose command to execute with arguments. For example, 'rm --all' to remove all stopped service containers.


arguments - Arguments
string. Optional. Use when action != Lock services && action != Combine configuration && action != Write service image digests.

Docker Compose command options. Ex:
For build command,
--pull --compress --parallel.


dockerHostEndpoint - Docker Host Service Connection
string.

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


nopIfNoDockerComposeFile - No-op if no Docker Compose File
boolean. Default value: false.

If the Docker Compose file does not exist, skip this task. This is useful when the task offers optional behavior based on the existence of a Docker Compose file in the repository.


requireAdditionalDockerComposeFiles - Require Additional Docker Compose Files
boolean. Default value: false.

Produces an error if the additional Docker Compose files do not exist. This overrides the default behavior which is to ignore a file if it does not exist.


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

Working directory for the Docker Compose command.


dockerComposePath - Docker Compose executable Path
string.

This docker-compose executable will be used if the path is provided.


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.

DockerComposeOutput
The path of the file(s) which contains the output of the command. This can contain multiple file paths (separated by newline characters) in case of dockerComposeRun command (one for running and one for down), dockerPush (one for each image pushed), dockerBuild (the build itself and all the tag commands) and dockerDigest (one for each image pulled). The other commands only output one file.

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