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 subcommand does not filter to services from current Compose file #9801

Closed
LatreviousYI opened this issue Aug 31, 2022 · 2 comments · Fixed by #9811
Closed

Logs subcommand does not filter to services from current Compose file #9801

LatreviousYI opened this issue Aug 31, 2022 · 2 comments · Fixed by #9811
Assignees

Comments

@LatreviousYI
Copy link

LatreviousYI commented Aug 31, 2022

docker compose -f ./ProcessFile/AIServer/yaml/AIServer.yaml logs command have same problem,and Compose v2 2.10.2 didn't fix it
#9705

@milas
Copy link
Contributor

milas commented Sep 2, 2022

Can you please provide a more detailed issue that includes the expected output as well as the actual output?

I am not seeing an issue on Compose v2.10.2:

services:
  foo:
    image: alpine
    init: true
    entrypoint: ["sleep", "infinity"]

  bar:
    image: alpine
    init: true
    entrypoint: ["sleep", "infinity"]
❯ docker compose -f compose.yaml ps
NAME                COMMAND             SERVICE             STATUS              PORTS
ps-bar-1            "sleep infinity"    bar                 running
ps-foo-1            "sleep infinity"    foo                 running

After removing bar from compose.yaml:

❯ docker compose -f compose-no-bar.yaml ps
NAME                COMMAND             SERVICE             STATUS              PORTS
ps-foo-1            "sleep infinity"    foo                 running

So I am not seeing output for containers that are not referenced by the Compose file when using the --file/-f option.

(NOTE: In this example, my project name is ps, so if I ran docker compose --project-name="ps" ps, I would see both containers as expected regardless of the Compose file.)

@milas milas self-assigned this Sep 2, 2022
@LatreviousYI
Copy link
Author

LatreviousYI commented Sep 4, 2022

hi,logs command have this issue too,not ps ,start or stop either.start,ps and stop command you guys areadly fixed it in edition 2.10.2
image
image

milas added a commit to milas/compose that referenced this issue Sep 6, 2022
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 changed the title Compose V2 docker compose -f ./ProcessFile/AIServer/yaml/AIServer.yaml logs command have same problem Logs subcommand does not filter to services from current Compose file Sep 8, 2022
milas added a commit that referenced this issue Sep 8, 2022
* logs: filter to services from current Compose file

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 #9705.

Fixes #9801.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants