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

Condense output of docker compose top #12381

Open
dmke opened this issue Dec 13, 2024 · 3 comments · May be fixed by #12391
Open

Condense output of docker compose top #12381

dmke opened this issue Dec 13, 2024 · 3 comments · May be fixed by #12391

Comments

@dmke
Copy link

dmke commented Dec 13, 2024

Description

In a current compose project, docker compose top reports the following:

$ docker compose top
myproject-converters-1
UID    PID      PPID     C    STIME   TTY   TIME       CMD
root   336052   335954   0    11:18   ?     00:00:01   ruby bin/server

myproject-redis-ephemeral-1
UID        PID      PPID     C    STIME   TTY   TIME       CMD
systemd+   336001   335887   0    11:18   ?     00:00:05   valkey-server *:6379

myproject-redis-persisted-1
UID    PID      PPID     C    STIME   TTY   TIME       CMD
root   336038   335921   0    11:18   ?     00:00:08   valkey-server *:6379

myproject-sidekiq-default-1
UID      PID      PPID     C    STIME   TTY   TIME       CMD
appuser   338516   338496   19   12:00   ?     00:00:09   sidekiq 7.3.6 default [0 of 3 busy]

myproject-watchtower-1
UID    PID      PPID     C    STIME   TTY   TIME       CMD
root   335931   335850   0    11:18   ?     00:00:00   /watchtower --label-enable --include-stopped --revive-stopped --cleanup --rolling-restart --stop-timeout=80s --http-api-update

myproject-web-1
UID      PID      PPID     C    STIME   TTY   TIME       CMD
appuser   338619   338597   0    12:00   ?     00:00:00   /bin/bash -e /rails/bin/docker-entrypoint.sh rails server
appuser   338653   338619   0    12:00   ?     00:00:00   flock -x /rails/data/migration-check.lock bundle exec rake db:prepare
appuser   338665   338653   46   12:00   ?     00:00:01   /usr/local/bundle/ruby/3.2.0/bin/rake db:prepare

I find this a bit wasteful, in regards to the screen estate. The output is also hard to grasp because the columns are not aligned across the various services.

Would you accept a PR to format the output to something like the following?

$ docker compose top
SERVICE                       UID        PID      PPID     C    STIME   TTY   TIME       CMD
myproject-converters-1        root       336052   335954   0    11:18   ?     00:00:01   ruby bin/server
myproject-redis-ephemeral-1   systemd+   336001   335887   0    11:18   ?     00:00:05   valkey-server *:6379
myproject-redis-persisted-1   root       336038   335921   0    11:18   ?     00:00:08   valkey-server *:6379
myproject-sidekiq-default-1   appuser    338516   338496   19   12:00   ?     00:00:09   sidekiq 7.3.6 default [0 of 3 busy]
myproject-watchtower-1        root       335931   335850   0    11:18   ?     00:00:00   /watchtower --label-enable --include-stopped --revive-stopped --cleanup --rolling-restart --stop-timeout=80s --http-api-update
myproject-web-1               appuser    338619   338597   0    12:00   ?     00:00:00   /bin/bash -e /rails/bin/docker-entrypoint.sh rails server
myproject-web-1               appuser    338653   338619   0    12:00   ?     00:00:00   flock -x /rails/data/migration-check.lock bundle exec rake db:prepare
myproject-web-1               appuser    338665   338653   46   12:00   ?     00:00:01   /usr/local/bundle/ruby/3.2.0/bin/rake db:prepare
@ndeloof
Copy link
Contributor

ndeloof commented Dec 16, 2024

compose top uses text/tabwriter which should manage alignment
columns are those reported by docker engine ContainerTop API, I agree we miss one to report the service process belongs to. Happy to review a PR if you can prepare one

@dmke
Copy link
Author

dmke commented Dec 16, 2024

Can I assume that ContainerTop returns always returns the columns in the same order, or shall I be defensive and ensure ordering of the container.Titles when running compose top?

@dmke dmke linked a pull request Dec 16, 2024 that will close this issue
@dmke
Copy link
Author

dmke commented Dec 16, 2024

@ndeloof, I have posted a first draft in #12391. Let me know what you think.

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