podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

Support depends_on type service_completed_successfully

Open micheljung opened this issue 3 years ago • 10 comments

Is your feature request related to a problem? Please describe.

The problem is that podman-compose is incompatible with current docker-compose.yml because it does not support service_completed_successfully.

According to the compose spec

  • condition: condition under which dependency is considered satisfied
    • service_started: is an equivalent of the short syntax described above
    • service_healthy: specifies that a dependency is expected to be "healthy" (as indicated by healthcheck) before starting a dependent service.
    • service_completed_successfully: specifies that a dependency is expected to run to successful completion before starting a dependent service.

Describe the solution you'd like podman-compose implements service_completed_successfully as per the spec.

Describe alternatives you've considered None

Additional context I didn't check if the other conditions are supported yet, but they should also be.

micheljung avatar Oct 19 '22 06:10 micheljung

It seems like service_healthy also does not work. service_started is the equivalent to no condition (default) and therefore works. Would be great to get these working!

mbergen avatar Dec 13 '22 11:12 mbergen

Actually, i think podman waits for the healthiness anyway, so anything one specifies behaves like service_healthy.

mdellweg avatar Sep 20 '23 06:09 mdellweg

Actually, i think podman waits for the healthiness anyway, so anything one specifies behaves like service_healthy.

Last time i checked it podman was not executing any healthchecks, it was only waiting for services to be started. That's a huge difference.

mbergen avatar Sep 20 '23 07:09 mbergen

I'm on the following versions and can confirm that service_healthy condition seems to be ignored and treated as service_started. podman-compose version 1.0.6 podman version 4.4.1

Greenall avatar Oct 04 '23 10:10 Greenall

any status update on this feature?

any way to workaround this?

kontsaki avatar Feb 09 '24 14:02 kontsaki

@kontsaki Have a look at #453, which has a preliminary implementation of depends_on.

TL;DR (maybe inaccurate!): podman-compose is calling podman commands directly to do all stuffs (e.g. executing podman start foo --bar), which do not provide a way of "depending on" another container, because it needs a daemon to do that (as Docker does). There are some workarounds:

  • podman-compose waits for all dependencies to start (dirty, but has been done in #453)
  • rely on podman socket and use its API to start instead of calling it directly (which is how docker-compose does; see discussion in https://github.com/containers/podman-compose/discussions/456; community has no motivation to move to this)
  • wait until Podman officially supports flags like --require bar (almost no way)

So, it is sad to say that there is still no good way to support it. I ended up having the container exit immediately when it fails to connect to the dependency container, and set restart: always.

w568w avatar Feb 10 '24 14:02 w568w

I ended up using docker-compose provided by https://github.com/docker/compose and it works as expected with podman as the backend.

I have also installed the compat package podman-docker on Fedora, not sure if this makes podman run as daemon but currently everything works with rootless podman and all docker-compose features.

kontsaki avatar Feb 10 '24 14:02 kontsaki

@mbergen, @mdellweg, @Greenall I just filed a dedicated issue for the problem with the service_healthy condition.

candleindark avatar Mar 06 '24 21:03 candleindark