Docker Compose task
Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019
Use this task to build, push or run multi-container Docker applications. This task can be used with a Docker registry or an Azure Container Registry.
Container registry types
Azure Container Registry
| Parameters | Description |
|---|---|
containerregistrytype (Container registry type) |
(Optional) Azure Container Registry if using ACR or Container Registry if using any other container registry. Default value: Azure Container Registry |
azureSubscriptionEndpoint (Azure subscription) |
(Required) Name of the Azure Service Connection. See Azure Resource Manager service connection to manually set up the connection. Argument aliases: azureSubscription |
azureContainerRegistry (Azure Container Registry) |
(Required) Name of the Azure Container Registry. Example: Contoso.azurecr.io |
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.
| Parameters | Description |
|---|---|
containerregistrytype (Container registry type) |
(Required) Azure Container Registry if using ACR or Container Registry if using any other container registry. Default value: Azure Container Registry |
dockerRegistryEndpoint (Docker registry service connection) |
(Required) Docker registry service connection. |
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
| Parameters | Description |
|---|---|
containerregistrytype (Container Registry Type) |
(Required) Azure Container Registry if using ACR or Container Registry if using any other container registry. Default value: Azure Container Registry |
azureSubscriptionEndpoint (Azure subscription) |
(Required) Name of the Azure Service Connection. |
azureContainerRegistry (Azure Container Registry) |
(Required) Name of the Azure Container Registry. |
dockerComposeFile (Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name = value pair on a new line. You need to use the | operator in YAML to indicate that newlines should be preserved. Example: dockerComposeFileArgs: DOCKER_BUILD_SOURCE=$(CustomVar) |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
additionalImageTags (Additional Image Tags) |
(Optional) Additional tags for the Docker images being built or pushed. Specify multiple tags with a line feed \n. |
includeSourceTags (Include Source Tags) |
(Optional) Include Git tags when building or pushing Docker images. Default value: false |
includeLatestTag (Include Latest Tag) |
(Optional) Include the latest tag when building or pushing Docker images. Default value: false |
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
| Parameters | Description |
|---|---|
containerregistrytype (Container Registry Type) |
(Required) Azure Container Registry if using ACR or Container Registry if using any other container registry. Default value: Azure Container Registry |
azureSubscriptionEndpoint (Azure subscription) |
(Required) Name of the Azure Service Connection. |
azureContainerRegistry (Azure Container Registry) |
(Required) Name of the Azure Container Registry. |
dockerComposeFile (Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name=value pair on a new line. |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
additionalImageTags (Additional Image Tags) |
(Optional) Additional tags for the Docker images being built or pushed. |
includeSourceTags (Include Source Tags) |
(Optional) Include Git tags when building or pushing Docker images. Default value: false |
includeLatestTag (Include Latest Tag) |
(Optional) Include the latest tag when building or pushing Docker images. Default value: false |
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
| Parameters | Description |
|---|---|
dockerComposeFile (Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name=value pair on a new line. |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
buildImages (Build Images) |
(Optional) Build images before starting service containers. Default value: true |
detached (Run in Background) |
(Optional) Run the service containers in the background. Default value: true |
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: false
Run a specific service image
| Parameters | Description |
|---|---|
dockerComposeFile (Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name=value pair on a new line. |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
serviceName (Service Name) |
(Required) Name of the specific service to run. |
containerName (Container Name) |
(Optional) Name of the specific service container to run. |
ports (Ports) |
(Optional) Ports in the specific service container to publish to the host. Specify each host-port:container-port binding on a new line. |
workDir (Working Directory) |
(Optional) The working directory for the specific service container. Argument aliases: workingDirectory |
entrypoint (Entry Point Override) |
(Optional) Override the default entry point for the specific service container. |
containerCommand (Command) |
(Optional) 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) |
(Optional) Run the service containers in the background. Default value: true |
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
| Parameters | Description |
|---|---|
dockerComposeFile (Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name=value pair on a new line. |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
removeBuildOptions (Remove Build Options) |
(Optional) Remove the build options from the output Docker Compose file. Default value: false |
baseResolveDirectory (Base Resolve Directory) |
(Optional) The base directory from which relative paths in the output Docker Compose file should be resolved. |
outputDockerComposeFile (Output Docker Compose File) |
(Required) Path to an output Docker Compose file. Default value: $(Build.StagingDirectory)/docker-compose.yml |
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
| Parameters | Description |
|---|---|
dockerComposeFile (Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name=value pair on a new line. |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
imageDigestComposeFile (Image Digest Compose File) |
(Required) Path to a Docker Compose file that is created and populated with the full image repository digests of each service's Docker image. Default value: $(Build.StagingDirectory)/docker-compose.images.yml |
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
| Parameters | Description |
|---|---|
dockerComposeFile (Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name=value pair on a new line |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
removeBuildOptions (Remove Build Options) |
(Optional) Remove the build options from the output Docker Compose file. Default value: false |
baseResolveDirectory (Base Resolve Directory) |
(Optional) The base directory from which relative paths in the output Docker Compose file should be resolved. |
outputDockerComposeFile (Output Docker Compose File) |
(Required) Path to an output Docker Compose file. Default value: $(Build.StagingDirectory)/docker-compose.yml |
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
| Parameters | Description |
|---|---|
dockerComposeFile(Docker Compose File) |
(Required) Path to the primary Docker Compose file to use. Default value: **/docker-compose.yml |
additionalDockerComposeFiles (Additional Docker Compose Files) |
(Optional) 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) |
(Optional) Environment variables to be set up during the command. Specify each name=value pair on a new line. |
projectName (Project Name) |
(Optional) Project name used for default naming of images and containers. Default value: $(Build.Repository.Name) |
qualifyImageNames (Qualify Image Names) |
(Optional) Qualify image names for built services with the Docker registry service connection's hostname if not otherwise specified. Default value: true |
action (Action) |
(Required) Select a Docker Compose action. Default value: Run a Docker Compose command |
dockerComposeCommand (Command) |
(Required) Docker Compose command to execute with the help of arguments. For example, rm to remove all stopped service containers. |
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
Open source
This task is open source on GitHub. Feedback and contributions are welcome.
FAQ
Feedback
Issottometti u ara feedback għal