Skip to content

fix: podman-compose down should not stop the upstream dependencies. #1283

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

Merged

Conversation

lisongmin
Copy link
Contributor

Say there is an app service depends on a db service, when we run podman-compose down app, the db service should not be stopped.

This will fix #1260

@lisongmin lisongmin force-pushed the fix-stop-wrong-dependents-on-compose-down branch from ce00281 to 9757ebd Compare August 9, 2025 14:51
Say there is an app service depends on a db service,
when we run `podman-compose down app`, the db service should not be stopped.

Signed-off-by: Songmin Li <[email protected]>
@lisongmin lisongmin force-pushed the fix-stop-wrong-dependents-on-compose-down branch from 9757ebd to 4aa11de Compare August 9, 2025 15:30
Previously, get_excluded() determined the dependency field based on
args.command, but this caused issues during teardown actions where
`podman-compose up` would pass `command=up` while needing dependents
rather than dependencies.

This change introduces an explicit dep_field parameter to eliminate
the ambiguity and ensure correct dependency resolution.

Signed-off-by: Songmin Li <[email protected]>
@lisongmin
Copy link
Contributor Author

Say there is an app service depends on db service, like:

services:
    app:
        image: myapp
        restart: always
        depends_on:
            - db
    db:
        image: mydb

The behavior of docker-compose and podman-compose is different as follows:

scenario docker-compose behavior current podman-compose behavior new podman-compose behavior
down all stop and remove db, app same as docker-compose same as docker-compose
down app stop and remove app stop and remove db, app same as docker-compose
down db stop and remove db stop but failed to remove db stop and remove db, app

podman-compose relies on podman's --requires to determine the dependency between containers.
When we try to remove the db container, podman will refuse to do so because it is required by the
app container. And we can not create a new db container without removing the old one.

Moreover, if we rename the db container, and create a new one, the dependencies will lost,
and there may be two db containers running at the same time, which is not what we want.
So we should remove both db and app containers when we want to remove the db container.

this behavior can only changed when podman support dynamic dependencies, which is not supported now.

@lisongmin lisongmin force-pushed the fix-stop-wrong-dependents-on-compose-down branch 2 times, most recently from 27d0e6e to 6306e19 Compare August 10, 2025 15:20
@lisongmin lisongmin force-pushed the fix-stop-wrong-dependents-on-compose-down branch from 6306e19 to cd25efa Compare August 10, 2025 15:41
@p12tic
Copy link
Collaborator

p12tic commented Aug 21, 2025

Great, thanks!

@p12tic p12tic merged commit ffe2a29 into containers:main Aug 21, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman compose down <service> should not stop dependencies
2 participants