Markus
Markus

Reputation: 645

Azure DevOps: Compose Error: The current Compose file version is not compatible with your engine version

With AzureDevOps I get the following error since yesterday, before that everything worked fine for months:

The current Compose file version is not compatible with your engine version. Please 
upgrade your Compose file to a more recent version, or set a COMPOSE_API_VERSION in your 
environment.

In Azure-DevOps I use in the pipeline:

  - task: DockerCompose@0
    displayName: Run services
    inputs:
     containerregistrytype: 'Container Registry'         
     dockerComposeFile: 'build/docker/docker-compose.yml'
     dockerComposeFileArgs: 'DOCKER_BUILD_SOURCE=$(System.DefaultWorkingDirectory)'
     action: 'Run services'
     buildImages: false

My docker-compose (docker-compose.yml) file looks like this (details changed):

version: '3.0'

services:
  sqlserver:
    image: willh/mssql-server-windows-developer:latest
    container_name: sqlserver
    shm_size: 4gb
    ports:
      - "1433:1433"
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=a(!)Passcode

I realized the updated microsoft build agent Image:

from: https://github.com/actions/runner-images/blob/win22/20230129.1/images/win/Windows2022-Readme.md

which worked well containing:

to: https://github.com/actions/runner-images/blob/win22/20230206.1/images/win/Windows2022-Readme.md

which does not work containing:

But i do not see how I can get it to work again. Which COMPOSE_API_VERSION would I have to set? The same as I have in the docker-compose.yml file?

Upvotes: 0

Views: 1245

Answers (2)

Markus
Markus

Reputation: 645

The following solved the problem as a workaround:

- task: DockerCompose@0
    displayName: Run services
    inputs:
    action: Run services
    projectName: my-project
    ...
    dockerComposePath: 'C:\ProgramData\docker\cli-plugins\docker-compose.exe'

Important was to set the projectName as well as the dockerComposePath.

See discussions in:

Hopefully this will be fixed in:

Upvotes: 1

Sebastian Schütze
Sebastian Schütze

Reputation: 761

The error message you are receiving indicates that the version of Docker Compose being used is not compatible with the version specified in your Docker Compose file (docker-compose.yml). The version specified in your Docker Compose file is 3.0, but the version of Docker Compose installed on the updated build agent image is 2.15.1.

To resolve this issue, you can either upgrade the Docker Compose file to a version that is compatible with the installed version of Docker Compose, or you can set the COMPOSE_API_VERSION environment variable to the version specified in the Docker Compose file.

In your case, you could set the COMPOSE_API_VERSION environment variable to 3.0:

env:
  COMPOSE_API_VERSION: '3.0'

and add this environment variable to the Azure DevOps pipeline task:

- task: DockerCompose@0
  displayName: Run services
  inputs:
    containerregistrytype: 'Container Registry'
    dockerComposeFile: 'build/docker/docker-compose.yml'
    dockerComposeFileArgs: 'DOCKER_BUILD_SOURCE=$(System.DefaultWorkingDirectory)'
    action: 'Run services'
    buildImages: false
    env:
      COMPOSE_API_VERSION: '3.0'

This should allow the pipeline task to use the correct version of Docker Compose and avoid the compatibility error.

Upvotes: 1

Related Questions