DockerCompose@0 - Docker Compose v0 task

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

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 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 - Entrypoint Override
string. Optional. Use when action = Run a specific service.

Specifies an override value for the default entry point for 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.


dockerHostEndpoint - Docker Host 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.


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

None.

Remarks

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