Skip to content
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

logs: filter to services from current Compose file #9811

Merged
merged 2 commits into from Sep 8, 2022

Conversation

milas
Copy link
Contributor

@milas milas commented Sep 6, 2022

What I did
When using the file model, only attach to services referenced in the active Compose file.

For example, let's say you have compose-base.yaml and compose.yaml, where the former only has a
subset of the services but are both run as part of the same named project.

Project based command:

docker compose -p myproj logs

This should return logs for active services based
on the project name, regardless of Compose file
state on disk.

File based command:

docker compose --file compose-base.yaml logs

This should return logs for ONLY services that are defined in compose-base.yaml. Any other services are considered 'orphaned' within the context of the command and should be ignored.

Related issue
See also #9705.

Fixes #9801.

(not mandatory) A picture of a cute animal, if possible in relation with what you did
photo of a quokka standing on its hind legs

When using the file model, only attach to services
referenced in the active Compose file.

For example, let's say you have `compose-base.yaml`
and `compose.yaml`, where the former only has a
subset of the services but are both run as part of
the same named project.

Project based command:
```
docker compose -p myproj logs
```
This should return logs for active services based
on the project name, regardless of Compose file
state on disk.

File based command:
```
docker compose --file compose-base.yaml logs
```
This should return logs for ONLY services that are
defined in `compose-base.yaml`. Any other services
are considered 'orphaned' within the context of the
command and should be ignored.

See also docker#9705.

Fixes docker#9801.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
@milas milas requested a review from a team September 6, 2022 21:23
@milas milas self-assigned this Sep 6, 2022
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Copy link
Member

@nicksieger nicksieger left a comment

Choose a reason for hiding this comment

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

LGTM, agree that it would be nice to have project processing and filtering like this applied in the command, but this works and isn't too onerous.

@milas milas merged commit 61845dd into docker:v2 Sep 8, 2022
@milas milas deleted the compose-logs-filter branch September 8, 2022 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logs subcommand does not filter to services from current Compose file
2 participants