Skip to content

feat: add recursive discovery of compose files up to 10 levels #1268

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

arkhan
Copy link

@arkhan arkhan commented Jul 8, 2025

This feature allows podman-compose to locate a compose file (e.g., docker-compose.yml, compose.yml, etc.) when executed from deep within a project structure.

If a user runs podman-compose ps from a subdirectory like project/addons/module/component, the tool will search upward through parent directories (up to 10 levels) to find a compose file located in the root of the project (e.g., project/).

This improves usability by eliminating the need to manually navigate to the project root or specify the --file option.

Notes:

  • Supports common file names like docker-compose.yml, compose.yml
  • Max search depth: 10 parent directories

Contributor Checklist:

If this PR adds a new feature that improves compatibility with docker-compose, please add a link
to the exact part of compose spec that the PR touches.

For any user-visible change please add a release note to newsfragments directory, e.g.
newsfragments/my_feature.feature. See newsfragments/README.md for more details.

All changes require additional unit tests.

arkhan added 2 commits July 8, 2025 09:49
This feature allows podman-compose to locate a compose file
(e.g., docker-compose.yml, compose.yml, etc.) when executed
from deep within a project structure.

If a user runs `podman-compose ps` from a subdirectory like
`project/addons/module/component`, the tool will search
upward through parent directories (up to 10 levels) to find
a compose file located in the root of the project (e.g., `project/`).

This improves usability by eliminating the need to manually
navigate to the project root or specify the `--file` option.

Notes:
- Supports common file names like `docker-compose.yml`, `compose.yml`
- Max search depth: 10 parent directories
current_dir = os.path.abspath(start_dir)

for depth in range(max_depth):
# Search for compose files in current directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obvious comment

Copy link
Collaborator

@p12tic p12tic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! Please add an integration test in tests/integration. Also there's a pylint error caught by CI

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.

2 participants