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

V2:docker compose ps command and docker-compose ps command get content not the same #9705

Closed
LatreviousYI opened this issue Aug 2, 2022 · 8 comments · Fixed by #9375
Closed
Assignees
Labels

Comments

@LatreviousYI
Copy link

LatreviousYI commented Aug 2, 2022

Description

Steps to reproduce the issue:
1.docker compose -f /home/kerwin/process_file/test_fastapi_v2_update/yaml/test_fastapi_v2_update.yaml ps
2.docker-compose -f /home/kerwin/process_file/test_fastapi_v2_update/yaml/test_fastapi_v2_update.yaml ps
3.

Describe the results you received:
output of docker compose

# docker compose -f test_fastapi_v2_update.yaml ps
NAME                COMMAND                  SERVICE             STATUS              PORTS
test_fastapi        "bash -c 'python tes…"   test_fastapi        running             0.0.0.0:6898->8000/tcp, :::6898->8000/tcp
test_fastapi_v1     "bash -c 'python tes…"   test_fastapi_v1     running             0.0.0.0:9898->8000/tcp, :::9898->8000/tcp
test_fastapi_v2     "bash -c 'python tes…"   test_fastapi_v2     running             0.0.0.0:9899->8000/tcp, :::9899->8000/tcp

Describe the results you expected:
output of docker-compose

# docker-compose -f test_fastapi_v2_update.yaml ps
     Name                Command           State                    Ports                  
-------------------------------------------------------------------------------------------
test_fastapi_v1   bash -c python test.py   Up      0.0.0.0:9898->8000/tcp,:::9898->8000/tcp
test_fastapi_v2   bash -c python test.py   Up      0.0.0.0:9899->8000/tcp,:::9899->8000/tcp

Additional information you deem important (e.g. issue happens only occasionally):

Compose file:

# cat test_fastapi_v2_update.yaml
services:
  test_fastapi_v1:
    command: bash -c "python test.py"
    container_name: test_fastapi_v1
    image: python:fastapi_comp
    logging:
      driver: json-file
      options:
        max-file: '3'
        max-size: 500mb
    ports:
    - 9898:8000
    restart: always
    volumes:
    - /home/kerwin/test_fastpi:/home/kerwin/test_fastpi
    working_dir: /home/kerwin/test_fastpi
  test_fastapi_v2:
    command: bash -c "python test.py"
    container_name: test_fastapi_v2
    image: python:fastapi_comp
    logging:
      driver: json-file
      options:
        max-file: '3'
        max-size: 500mb
    ports:
    - 9899:8000
    restart: always
    volumes:
    - /home/kerwin/test_fastpi:/home/kerwin/test_fastpi
    working_dir: /home/kerwin/test_fastpi

Output of docker compose version:
Docker Compose version v2.6.0

Output of docker info:

root@ubuntu:/home/kerwin/process_file# docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  compose: Docker Compose (Docker Inc., v2.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 5
  Running: 4
  Paused: 0
  Stopped: 1
 Images: 9
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc version: v1.1.2-0-ga916309
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.0-41-generic
 Operating System: Ubuntu 22.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.898GiB
 Name: ubuntu
 ID: LRX2:64LM:NEGK:BAPB:M2FO:6XXV:RNDE:PGM3:3ZS6:VDNW:CN2C:BACX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:
ubuntu-22.04

@glours
Copy link
Contributor

glours commented Aug 2, 2022

Hello @kerwinLV
Yes indeed, we provide now the real status of containers instead of the state and also display the service names (which may differ from the container ones)
That the kind of improvement you may expect from a new major version.
So what is your issue with those changes?

@LatreviousYI
Copy link
Author

so your mean it's the correct output? right? kind of confuse, I want the output is isolated every yaml manage one each other compose

@laurazard
Copy link
Member

After looking deeper into this, it looks like the problem @kerwinLV was trying to report was that in compose v2, a service that is not defined in the compose file provided with -f is showing up. This is a similar issue to #9671, although I don't know if the changes in #9671 will fix it. I'll check

@laurazard laurazard self-assigned this Aug 2, 2022
@laurazard
Copy link
Member

Ahh, it doesn't. I'll see if I can make some changes to #9375 to apply the same logic to compose ps

@LatreviousYI
Copy link
Author

This is another service YAML file, I wish this can help find the real issue

root@ubuntu:/home/kerwin/process_file# cat test_fastapi/yaml/test_fastapi.yaml 
services:
  test_fastapi:
    command: bash -c "python test.py"
    container_name: test_fastapi
    image: python:fastapi_comp
    logging:
      driver: json-file
      options:
        max-file: '3'
        max-size: 500mb
    ports:
    - 6898:8000
    restart: always
    volumes:
    - /home/kerwin/test_fastpi:/home/kerwin/test_fastpi
    working_dir: /home/kerwin/test_fastpi
root@ubuntu:/home/kerwin/process_file# docker compose -f test_fastapi/yaml/test_fastapi.yaml ps
NAME                COMMAND                  SERVICE             STATUS              PORTS
test_fastapi        "bash -c 'python tes…"   test_fastapi        running             0.0.0.0:6898->8000/tcp, :::6898->8000/tcp
test_fastapi_v1     "bash -c 'python tes…"   test_fastapi_v1     running             0.0.0.0:9898->8000/tcp, :::9898->8000/tcp
test_fastapi_v2     "bash -c 'python tes…"   test_fastapi_v2     running             0.0.0.0:9899->8000/tcp, :::9899->8000/tcp

@LatreviousYI
Copy link
Author

Oh, By the way, compose v2 can't via press TAB auto-completion. It kind of impacts user experience, ahh but it's' no big deal, don't put it on your mind, have a good day.

@LatreviousYI LatreviousYI changed the title docker compose ps command and docker-compose ps command get content not the same V2:docker compose ps command and docker-compose ps command get content not the same Aug 3, 2022
@LatreviousYI
Copy link
Author

Compose V2 restart command have same problem

@LatreviousYI
Copy link
Author

LatreviousYI commented Aug 29, 2022

docker compose -f ./ProcessFile/AIServer/yaml/AIServer.yaml logs command have same problem,hi @laurazard ,I didn't see Compose v2.10.2 fix it.please, thanks a lot.

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 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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants