Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: DockerCompose@1 failed with Version mismatch error #20275

Closed
4 of 7 tasks
CharanGali opened this issue Aug 9, 2024 · 6 comments
Closed
4 of 7 tasks

[BUG]: DockerCompose@1 failed with Version mismatch error #20275

CharanGali opened this issue Aug 9, 2024 · 6 comments

Comments

@CharanGali
Copy link

CharanGali commented Aug 9, 2024

New issue checklist

Task name

DockerCompose

Task version

1.243.1

Issue Description

A bug happened!

While using the task DockerCompose@1, received below error and failed

##[error]Version mismatch: file D:\a\1\s\Sources\Integration Tests\Docker\docker-compose-win2022.yml specifies version 3.9 but extension file C:\agents\3.242.1.docker-compose.1723125556266.yml uses version 1
##[error]The process 'C:\ProgramData\docker-compose\docker-compose.exe' failed with exit code 1

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows

Relevant log output

While using the task DockerCompose@1, received below error and failed

##[error]Version mismatch: file D:\a\1\s\Sources\Integration Tests\Docker\docker-compose-win2022.yml specifies version 3.9 but extension file C:\agents\3.242.1\.docker-compose.1723125556266.yml uses version 1
##[error]The process 'C:\ProgramData\docker-compose\docker-compose.exe' failed with exit code 1

Full task logs with system.debug enabled

While using the task DockerCompose@1, received below error and failed

##[error]Version mismatch: file D:\a\1\s\Sources\Integration Tests\Docker\docker-compose-win2022.yml specifies version 3.9 but extension file C:\agents\3.242.1.docker-compose.1723125556266.yml uses version 1
##[error]The process 'C:\ProgramData\docker-compose\docker-compose.exe' failed with exit code 1

Repro steps

While using the task DockerCompose@1, received below error and failed

##[error]Version mismatch: file D:\a\1\s\Sources\Integration Tests\Docker\docker-compose-win2022.yml specifies version 3.9 but extension file C:\agents\3.242.1\.docker-compose.1723125556266.yml uses version 1
##[error]The process 'C:\ProgramData\docker-compose\docker-compose.exe' failed with exit code 1
@CharanGali
Copy link
Author

@ivanduplenskikh

Could you please help us to sort as this occurred after latest changes done to this task

@ivanduplenskikh
Copy link
Contributor

@CharanGali, since version property is obsolete, the temporary fix is removing the version property from your own docker compose file if this error is blocking for you.
The PR that removes the version property from generated YAML files has been merged and already released.

Could you please provide a minimal example with a pipeline and a docker-compose YAML file to reproduce it?

@CharanGali
Copy link
Author

CharanGali commented Aug 12, 2024

@ivanduplenskikh Thanks for your response and below is the requested information.

We have used the below task in pipeline.

- task: DockerCompose@1
   displayName: 'Run a Docker Compose command'
   inputs:
     containerregistrytype: 'Container Registry'
     dockerRegistryEndpoint: '<<Registry Name>>'
     dockerComposeFile: 'Sources\Integration Tests\Docker\docker-compose-win2022.yml'
     dockerComposePath : '$(dockerComposePath)\docker-compose.exe'
     action: 'Run a Docker Compose command'
     dockerComposeCommand: 'up'
     arguments: '-d'

docker-compose-win2022.yml file contents are as below

version: '3.9'
services:
  siteserver:    
    container_name: tests
    image: <<CustomImageName from above registry>>
    ports:
      - "1433:1433"
    volumes:
        - type: bind
          source: c:/sites
          target: c:/sitesmount

Also, we have tried to remove the version from above docker file - still we receive the message as compose path is not found

##[error]Unhandled: Unable to locate executable file: 'C:\ProgramData\docker-compose\docker-compose.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

Could you please help us ?

@CharanGali
Copy link
Author

@ivanduplenskikh

Also, to add on - when we remove the dockercomposepath from task. we receive error as ##[error]The process 'C:\Windows\system32\docker.exe' failed with exit code 15

@ivanduplenskikh
Copy link
Contributor

@CharanGali, you have four different errors and warnings in this case.


The warning message about different version properties in YAML

The message about different version in your pipeline output indicates that you have two different versions in a generated task's YAML and your docker-compose-win2022.yml YAML

##[error]Version mismatch: file D:\a\1\s\Sources\Integration Tests\Docker\docker-compose-win2022.yml specifies version 3.9 but extension file C:\agents\3.242.1\.docker-compose.1723125556266.yml uses version 1

You can resolve this by removing the version property from your YAML.
Additionally, you mentioned that you use DockerCompose task v1.243.1 but this version of task doesn't include the version property in the generated YAML file. This issue was fixed in #20197.
I've tested it on my own pipeline, and didn't encounter any errors, except for the default warning message from Docker.

time="2024-08-13T13:14:13+02:00" level=warning msg="C:\\a\\_work\\1\\s\\DockerComposeV0\\docker-compose-win2022.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion"

This default Docker warning message means that you don't need to specify the version.


Exit code 1

The error in your output indicates that your container terminated due to a problem with an image, an invalid reference, or a similar issue.
You can enable the system diagnostics checkbox in your pipeline to obtain more detailed information about your error.
Additionally, you might want to try executing the docker compose command locally to check your environment and determine whether you can use this docker compose YAML file without errors.

##[error]The process 'C:\ProgramData\docker-compose\docker-compose.exe' failed with exit code 1

The problem with dockerComposePath input

You mentioned that you removed the version from Docker file and still received the message that the compose path is not found.

##[error]Unhandled: Unable to locate executable file: 'C:\ProgramData\docker-compose\docker-compose.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

The version property doesn't affect this input. This error usually appears when there are no Docker Compose instances at the specified path.
In your case you should have the Docker Compose executable located at C:\ProgramData\docker-compose\docker-compose.exe.


Exit code 15

I see that your next step was deleting the dockerComposePath input, which helped you proceed with task interaction, but you encountered another error.

##[error]The process 'C:\Windows\system32\docker.exe' failed with exit code 15

This exit code usually appears when you have a project name that doesn't pass the strict Docker Compose constraints for project names.
The default behavior for the Docker Compose utility in this task is to indicate an exit code. If you want to get a detailed information you can enable the system diagnostics checkbox in your pipeline to obtain more detailed information about your error.
To avoid this situation, you may specify projectName input in your pipeline.


Here is my minimal working example based on yours. In this example Docker Compose doesn't produce any warnings or errors.

service.yml

services:
  service:
    image: ubuntu:latest

azure-pipelines.yml

variables:
  - name: System.Debug
    value: true

steps:
  - task: DockerCompose@1
    displayName: Run a Docker Compose command
    inputs:
      containerregistrytype: 'Container Registry'
      dockerComposeFile: './service.yml'
      action: 'Run a Docker Compose command'
      projectName: 'test'
      dockerComposeCommand: 'up'
      arguments: '-d'

@CharanGali
Copy link
Author

@ivanduplenskikh

Thanks for your inputs. we are able to use the latest version of DockerCompose@1 task and execute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants