containers / podman-compose

a script to run docker-compose.yml using podman
GNU General Public License v2.0
5.05k stars 481 forks source link

Container dependencies are not satisfied with multi-level dependent one-off container #683

Open skateman opened 1 year ago

skateman commented 1 year ago

Describe the bug When a container depends on a one-off task container that depends on another container, e.g. a web server depending on DB migrations depending on a database, its dependency graph gets broken as soon as the one-off task exits, regardless of its exit code.

This issue was not present in version 1.0.3 and it was introduced in 1.0.6.

To Reproduce

version: "3"
services:
  first:
    image: docker.io/library/alpine
    command: sleep infinity
  second:
    image: docker.io/library/alpine
    command: whoami
    depends_on:
      - first
  third:
    image: docker.io/library/alpine
    command: sleep infinity
    depends_on:
      - first
      - second

Expected behavior The first and third services run properly and the second one exits successfully.

Actual behavior The dependency graph gets broken as the third service depending on the second cannot be started.

Output

$ podman-compose version
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.5.0
podman-compose version 1.0.6
podman --version 
podman version 4.5.0
exit code: 0

$ podman-compose up
...
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=test', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'test_default']
podman run --name=test_first_1 -d --label io.podman.compose.config-hash=48081b958c63b73cedfc896d9abff3afb926613125ab6be217a659695dc7fd5f --label io.podman.compose.project=test --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@test.service --label com.docker.compose.project=test --label com.docker.compose.project.working_dir=/home/skateman/Repositories/Insights/test --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=first --net test_default --network-alias first docker.io/library/alpine sleep infinity
b86fe2a66161c19c047b258f048304b938596863cf36550adcd842a4f7c0243c
exit code: 0
['podman', 'network', 'exists', 'test_default']
podman run --name=test_second_1 -d --requires=test_first_1 --label io.podman.compose.config-hash=48081b958c63b73cedfc896d9abff3afb926613125ab6be217a659695dc7fd5f --label io.podman.compose.project=test --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@test.service --label com.docker.compose.project=test --label com.docker.compose.project.working_dir=/home/skateman/Repositories/Insights/test --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=second --net test_default --network-alias second docker.io/library/alpine whoami
838e3b41454619be5ef67740e646efb361bc9f11a6e2414ab86b887b85b825fd
exit code: 0
['podman', 'network', 'exists', 'test_default']
podman run --name=test_third_1 -d --requires=test_second_1,test_first_1 --label io.podman.compose.config-hash=48081b958c63b73cedfc896d9abff3afb926613125ab6be217a659695dc7fd5f --label io.podman.compose.project=test --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@test.service --label com.docker.compose.project=test --label com.docker.compose.project.working_dir=/home/skateman/Repositories/Insights/test --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=third --net test_default --network-alias third docker.io/library/alpine sleep infinity
Error: generating dependency graph for container 59713c8008dfab964ab9de7019221c2c444867b66a06bd8e7e63348e3dc2a302: container 838e3b41454619be5ef67740e646efb361bc9f11a6e2414ab86b887b85b825fd depends on container b86fe2a66161c19c047b258f048304b938596863cf36550adcd842a4f7c0243c not found in input list: no such container
exit code: 127
podman start test_third_1
Error: unable to start container "59713c8008dfab964ab9de7019221c2c444867b66a06bd8e7e63348e3dc2a302": generating dependency graph for container 59713c8008dfab964ab9de7019221c2c444867b66a06bd8e7e63348e3dc2a302: container 838e3b41454619be5ef67740e646efb361bc9f11a6e2414ab86b887b85b825fd depends on container b86fe2a66161c19c047b258f048304b938596863cf36550adcd842a4f7c0243c not found in input list: no such container
exit code: 125

Environment:

Additional context

$ podman-compose ps
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.5.0
podman ps -a --filter label=io.podman.compose.project=test
CONTAINER ID  IMAGE                            COMMAND         CREATED        STATUS                    PORTS       NAMES
8bcf6ca32b74  docker.io/library/alpine:latest  sleep infinity  6 seconds ago  Up 7 seconds                          test_first_1
ef75a020d3dc  docker.io/library/alpine:latest  whoami          5 seconds ago  Exited (0) 5 seconds ago              test_second_1
0ac117f663ef  docker.io/library/alpine:latest  sleep infinity  3 seconds ago  Created                               test_third_1
exit code: 0
skateman commented 1 year ago

I traced this back to #425 and https://github.com/containers/podman-compose/commit/d6e21dc7523bd26b3526cdb7beb7c88c86c750f1, apparently --requires doesn't take into account one-off containers :disappointed:

justgivemesomething commented 10 months ago

@skateman Hi! Did you manage to find a solution?

skateman commented 10 months ago

Not really, I am using docker-compose instead...colleagues went with donwgrading.

SohanTirpude commented 6 months ago

This issue is still seen

Renlor commented 5 months ago

This is still an issue, just ran into it today trying to migrate a project from docker-compose to podman-compose.

dev01-isarflow commented 5 months ago

Still an issue with using podman version: 4.9.4

CorentinWicht commented 4 weeks ago

Still an issue with using podman version: 4.9.4

Same here: https://github.com/taigaio/taiga-docker/issues/138

Any fix yet?