microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

docker-compose vs. docker compose #17051

Open gimlichael opened 1 year ago

gimlichael commented 1 year ago

I looked through the code after I experience some issues on Azure Virtual Machine Scale Set; it looks like this DockerCompose@0 need a much needed upgrade to V2+: https://docs.docker.com/compose/compose-file/compose-versioning/

docker-compose is deprecated; docker compose is the "new" syntax.

Please consider a DockerCompose@2 using docker compose command instead of docker-compose.

https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/DockerComposeV0/dockercomposeconnection.ts

Its probably not as simple as changing this: this.dockerComposePath = tl.which("docker-compose"); to this.dockerComposePath = tl.which("docker compose");.

    private setDockerComposePath(): void {
        //Priority to docker-compose path provided by user
        this.dockerComposePath = tl.getInput('dockerComposePath');
        if (!this.dockerComposePath) {
            //If not use the docker-compose avilable on agent
            this.dockerComposePath = tl.which("docker-compose");
            if (!this.dockerComposePath) {
                throw new Error("Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' ");
            }
        } else {
            console.log("Using docker-compose from 'dockerComposePath' ");
        }
    }
Strayfe commented 1 year ago

This is affecting us too.

We need to be able to use BuildKit which is now the default in docker compose v2+ and the variable DOCKER_BUILDKIT: 1 does not appear to be working correctly in the current version of DockerCompose@0.

For now, the workaround my colleague Joe 'big'ol brass nuts' de Ronde has created is to:

We did try setting an alias in ~/.bashrc first but this did not return the desired results.

The inspiration for this workaround: https://stackoverflow.com/questions/72099653/how-to-alias-docker-compose-to-docker-compose

gimlichael commented 1 year ago

This is affecting us too.

We need to be able to use BuildKit which is now the default in docker compose v2+ and the variable DOCKER_BUILDKIT: 1 does not appear to be working correctly in the current version of DockerCompose@0.

For now, the workaround my colleague Joe 'big'ol brass nuts' de Ronde has created is to:

  • use a self-hosted build agent
  • create an alias file /bin/docker-compose that contains docker compose "$@"
  • set the docker task variable `dockerComposePath: '/bin/docker-compose'
- task: DockerCompose@0
    displayName: docker compose build
    inputs:
      dockerComposePath: '/bin/docker-compose'

We did try setting an alias in ~/.bashrc first but this did not return the desired results.

The inspiration for this workaround: https://stackoverflow.com/questions/72099653/how-to-alias-docker-compose-to-docker-compose

Nice workaround; however, I need to be able to switch between managed and VMSS for my pipeline, so I opt-in for adding a custom script to the "Extensions + applications" blade:

sudo apt-get update
sudo apt-get install docker-compose-plugin
sudo apt-get  -y install docker-compose

Not pretty, but at least it is compatible with that old version.

janosroden commented 1 year ago

You can also use the docker task with "login" command and then just call docker compose as usual from a script.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

kurt-mueller-osumc commented 1 year ago

Let's keep this issue alive... can't we get at least a version 1 of this task with the latest docker compose?

Mahdibenamor commented 1 year ago

Any update about this issue, it blocks us

GuidDotEmpty commented 9 months ago

please fix this

benlings commented 5 months ago

The latest runner images since 1st April 2024 remove docker-compose, so any hosted pipeline in Azure DevOps that uses DockerCompose@0 will fail with the error Unhandled: Docker Compose was not found.