DockerCompose@0 - Docker Compose v0 task

Build, push or run multi-container Docker applications. Use this task with Docker or the Azure Container registry.

Important

The DockerCompose@0 task is deprecated. The task uses docker-compose v1 which no longer receives update since July 2023. To use docker compose v2, use the DockerCompose@1 task. For more information, see DockerCompose@0 uses Docker Compose v2 in v1 compatibility mode.

Build, push or run multi-container Docker applications. Use this task with Docker or the Azure Container registry.

Syntax

# Docker Compose v0
# Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.
- task: DockerCompose@0
  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.
# Docker Compose v0
# Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.
- task: DockerCompose@0
  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).
# Docker Compose v0
# Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.
- task: DockerCompose@0
  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. 
  # 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).

Inputs

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

Specifies an Azure Container Registry type if using ACR. Specify a Container Registry type if using any other container registry.


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

Specifies a Docker registry service connection. Required when commands need to authenticate using a registry.


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

Specifies an Azure subscription. Name of the Azure Service Connection. To manually set up the connection, see Azure Resource Manager service connection.


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

Specifies an Azure Container Registry.


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

Specifies the file path to the primary Docker Compose file.


additionalDockerComposeFiles - Additional Docker Compose Files
string.

Specifies additional Docker Compose files that are 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.

Specifies any environment variables that are set.

Format as follows:

  • List each name=value pair on a new line.
  • Use the | operator in YAML to preserve new lines.

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

Specifies the project name to use by default to name images and containers.


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

By default, specifies the Docker registry service connection's hostname.


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.

Specifies a Docker Compose action from the list of allowed values.


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

Specifies additional tags for the Docker images being built or pushed. You can specify multiple tags separating each with a line feed \n.


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

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

Specifies the latest tag when building or pushing Docker images.


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

Specifies build images before starting service containers.


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

Specifies the name of the service you want to run.


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

Specifies the name of the service container you want to use.


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

Specifies ports in the service container to publish to the host. Add 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.

Specifies the working directory for the service container.


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

Specifies an override value for the default entry point of the service container.


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

Specifies the command to run in the 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.

Specifies the service containers to run in the background.


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

Specifies all containers that should stop 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.

Specifies the 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.

Specifies if build options should be removed from the output Docker Compose file.


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

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

Specifies the path to an output Docker Compose file.


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

Specifies the 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.

Specifies Docker Compose command options.

Example: For the build command, --pull --compress --parallel.


dockerHostEndpoint - Docker Host Service Connection
string.

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


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

Specifies a value to skip the task if the Docker Compose file does not exist. This option 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.

Specifies a value to produce an error if the additional Docker Compose files do not exist. This option overrides the default behavior that would ignore a file if it does not exist.


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

Specifies the working directory for the Docker Compose command.


dockerComposePath - Docker Compose executable Path
string.

Specifies a path to determine if the docker-compose executable is used.


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 to the files which contain the output of the command. This can contain multiple file paths (separated by newline characters) such as, 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.

None.

Remarks

Important

The DockerCompose@0 task is deprecated. The task uses docker-compose v1 which no longer receives update since July 2023. To use docker compose v2, use the DockerCompose@1 task. For more information, see DockerCompose@0 uses Docker Compose v2 in v1 compatibility mode.

Use this task to build, push or run multi-container Docker applications. Use this task with a Docker registry or an Azure Container Registry.

Examples

Azure Container Registry

This YAML example specifies the inputs for Azure Container Registry:

variables:
  azureContainerRegistry: Contoso.azurecr.io
  azureSubscriptionEndpoint: Contoso
steps:
- task: DockerCompose@0
  displayName: Container registry login
  inputs:
    containerregistrytype: Azure Container Registry
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)

Other container registries

The containerregistrytype value is required when using any container registry other than ACR. Use containerregistrytype: Container Registry in this case.

This YAML example specifies a container registry other than ACR where Contoso is the name of the Docker registry service connection for the container registry:

- task: DockerCompose@0
  displayName: Container registry login
  inputs:
    containerregistrytype: Container Registry
    dockerRegistryEndpoint: Contoso

Build service images

This YAML example builds the image where the image name is qualified on the basis of the inputs related to Azure Container Registry:

- task: DockerCompose@0
  displayName: Build services
  inputs:
    action: Build services
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.yml
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    additionalImageTags: $(Build.BuildId)
    dockerComposeFileArgs: |
      firstArg=$(firstArg)
      secondArg=$(secondArg)

Push service images

This YAML example pushes an image to a container registry:

- task: DockerCompose@0
  displayName: Push services
  inputs:
    action: Push services
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.yml
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    additionalImageTags: $(Build.BuildId)

Run service images

This YAML example runs services:

- task: DockerCompose@0
  displayName: Run services
  inputs:
    action: Run services
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.ci.build.yml
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    buildImages: true
    abortOnContainerExit: true
    detached: true

Run a specific service image

This YAML example runs a specific service:

- task: DockerCompose@0
  displayName: Run a specific service
  inputs:
    action: Run a specific service
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.yml
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    serviceName: myhealth.web
    ports: 80:80
    detached: true

Lock service images

This YAML example locks services:

- task: DockerCompose@0
  displayName: Lock services
  inputs:
    action: Lock services
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.yml
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    outputDockerComposeFile: $(Build.StagingDirectory)/docker-compose.yml

Write service image digests

This YAML example writes service image digests:

- task: DockerCompose@0
  displayName: Write service image digests
  inputs:
    action: Write service image digests
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.yml
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    imageDigestComposeFile: $(Build.StagingDirectory)/docker-compose.images.yml 

Combine configuration

This YAML example combines configurations:

- task: DockerCompose@0
  displayName: Combine configuration
  inputs:
    action: Combine configuration
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.yml
    additionalDockerComposeFiles: docker-compose.override.yml
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    outputDockerComposeFile: $(Build.StagingDirectory)/docker-compose.yml

Run a Docker Compose command

This YAML example runs a docker Compose command:

- task: DockerCompose@0
  displayName: Run a Docker Compose command
  inputs:
    action: Run a Docker Compose command
    azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
    azureContainerRegistry: $(azureContainerRegistry)
    dockerComposeFile: docker-compose.yml 
    projectName: $(Build.Repository.Name)
    qualifyImageNames: true
    dockerComposeCommand: rm

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