puppetlabs / puppetlabs-docker

The Puppet Docker repository
Apache License 2.0
86 stars 298 forks source link

Support `docker-compose-plugin` as provider for `docker_compose` resource #891

Open kenyon opened 1 year ago

kenyon commented 1 year ago

Use Case

The docker_compose resource in this module should support the Docker Compose plugin.

Describe the Solution You Would Like

The docker_compose resource uses docker-compose-plugin rather than failing with Error: Could not find a suitable provider for docker_compose.

Describe Alternatives You've Considered

Installing standalone Docker Compose would be an alternative, but that is not supported by upstream per https://docs.docker.com/compose/install/ and upstream provides docker-compose-plugin as packages per https://docs.docker.com/compose/install/linux/.

Additional Context

See also: #839

vegaaz commented 1 year ago

This should be focused. According to the `documentation docker-compose v1 is going to loose support after june 2023.

vegaaz commented 1 year ago

@kenyon I am currently working on this.
Should we consider 'dropping support' for v1 and remove the code base?

kenyon commented 1 year ago

@vegaaz since v1 is unsupported upstream, removing support in this module would be 👍 from me.

robertc99 commented 1 year ago

docker-ce ships with a version of docker-compise on /usr/libexec/docker/cli-plugins/docker-compose but the module doesnt use it by default since its not on the standard path. If you change your path to include /usr/libexec/docker/cli-plugins/ before running puppet then docker_compose will find it and use it.

So all that needs to be done is adjust the default path used by the docker_compose resource But Im not sure how to do that.

kenyon commented 1 year ago

/usr/libexec is not supposed to be in PATH. I think it's best to stick with installing docker-compose-plugin per upstream documentation.

kenyon commented 1 year ago

Also, at least with Ubuntu and Red Hat packages provided by Docker, /usr/libexec/docker/cli-plugins/docker-compose is provided by the docker-compose-plugin package, not the docker-ce package.

robertc99 commented 1 year ago

Ok, the docker-compose is installed by the docker-compose-plugin package, not docker-ce itself. But even though it is installed, the docker module won't use it.

How do we get the module to use it if we dont change the path. Should the module create a link to it in /usr/local/bin?

robertc99 commented 1 year ago

I checked the upstream documentation, which recommends installing the plugin package. But even when you do that, the module doesnt use it.

kenyon commented 1 year ago

I checked the upstream documentation, which recommends installing the plugin package. But even when you do that, the module doesnt use it.

That's the point of this issue. The module needs to be updated so that it uses docker compose (with a space).

Mike7518 commented 9 months ago

A temporary solution that works for my use case is adding a script that redirects to compose plugin :

file { '/usr/bin/docker-compose':
  ensure  => file,
  mode    => '0755',
  content => 'docker compose "$@"',
}

docker_compose { 'my_compose':
  ...
}