Skip to content

align compose ps output with docker ps#10065

Merged
ndeloof merged 2 commits into
docker:v2from
ndeloof:align_ps_docker_cli
Dec 14, 2022
Merged

align compose ps output with docker ps#10065
ndeloof merged 2 commits into
docker:v2from
ndeloof:align_ps_docker_cli

Conversation

@ndeloof

@ndeloof ndeloof commented Dec 10, 2022

Copy link
Copy Markdown
Contributor

What I did
Align docker compose ps output with docker ps for an homogeneous user experience.
Ideally, would share code with docker/cli, maybe something to be considered for a future PR :P

example:

$ docker compose ps
NAME                IMAGE                   COMMAND                  SERVICE             CREATED              STATUS                        PORTS
sentences-db-1      gtardif/sentences-db    "docker-entrypoint.s…"   db                  About a minute ago   Up About a minute             5432/tcp
sentences-web-1     gtardif/sentences-web   "/dispatcher"            web                 About a minute ago   Up About a minute (healthy)   0.0.0.0:90->80/tcp
sentences-words-1   gtardif/sentences-api   "java -Xmx8m -Xms8m …"   words               About a minute ago   Up About a minute             0.0.0.0:95->8080/tcp
$ docker compose ps --format json |jq .
[
  {
    "ID": "e442fa59280ccd70d323c5f79fdc388622228c99abb3724e59419e9f84eb9d10",
    "Name": "sentences-web-1",
    "Image": "gtardif/sentences-web",
    "Command": "/dispatcher",
    "Project": "sentences",
    "Service": "web",
    "Created": 1670793089,
    "State": "running",
    "Status": "Up 2 minutes (healthy)",
    "Health": "healthy",
    ...

Related issue
fixes #6867

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@ndeloof
ndeloof force-pushed the align_ps_docker_cli branch 3 times, most recently from adbd655 to 1c59aa9 Compare December 11, 2022 14:04
@ndeloof ndeloof changed the title aligne compose ps output with docker ps align compose ps output with docker ps Dec 11, 2022
@ndeloof
ndeloof force-pushed the align_ps_docker_cli branch 9 times, most recently from 45136ba to 2f89b88 Compare December 11, 2022 20:03
@codecov

codecov Bot commented Dec 11, 2022

Copy link
Copy Markdown

Codecov Report

Base: 77.02% // Head: 76.98% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (902b7cd) compared to base (0368f19).
Patch coverage: 76.47% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##               v2   #10065      +/-   ##
==========================================
- Coverage   77.02%   76.98%   -0.04%     
==========================================
  Files           2        2              
  Lines         235      252      +17     
==========================================
+ Hits          181      194      +13     
- Misses         48       51       +3     
- Partials        6        7       +1     
Impacted Files Coverage Δ
pkg/e2e/framework.go 75.31% <76.47%> (+0.08%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ndeloof
ndeloof force-pushed the align_ps_docker_cli branch from ad9cc19 to 902b7cd Compare December 13, 2022 19:05
Comment thread cmd/compose/ps.go
return formatter.Print(containers, opts.Format, os.Stdout,
writer(containers),
"NAME", "COMMAND", "SERVICE", "STATUS", "PORTS")
"NAME", "IMAGE", "COMMAND", "SERVICE", "CREATED", "STATUS", "PORTS")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you think it would be weird to show the value/path from dockerfile for services that Compose built (instead of the auto-generated image name)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure. We would get this path from the current compose file, so this would only work when ran with a --file but not with --project-name, and even with this would assume the current compose file is in sync with listed containers.

func Print(toJSON interface{}, format string, outWriter io.Writer, writerFn func(w io.Writer), headers ...string) error {
switch strings.ToLower(format) {
case PRETTY, "":
case TABLE, PRETTY, "":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hurray for backwards compatibility 🎉

@ndeloof
ndeloof merged commit 8c39b5b into docker:v2 Dec 14, 2022
@ndeloof
ndeloof deleted the align_ps_docker_cli branch December 14, 2022 21:53
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.

docker-compose ps should show uptime

2 participants