Skip to content

Conversation

jsternberg
Copy link
Contributor

- What I did

Added platforms column to the docker ps output.

- How I did it

Utilized the change in moby/moby#49407 to retrieve the platform and modified the default table output to include it.

- How to verify it

docker run -d --name foo nginx:alpine
docker ps

- Description for the changelog

- `docker ps` now includes the platform of the image that is being run.

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.44%. Comparing base (c962084) to head (48202fb).
Report is 32 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (c962084) and HEAD (48202fb). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (c962084) HEAD (48202fb)
21 17
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5804       +/-   ##
===========================================
- Coverage   59.26%   44.44%   -14.83%     
===========================================
  Files         353        6      -347     
  Lines       29540      261    -29279     
===========================================
- Hits        17508      116    -17392     
+ Misses      11052      139    -10913     
+ Partials      980        6      -974     

@jsternberg
Copy link
Contributor Author

For what it's worth, I was looking at the output and I'm not sure platform should be included in the main template since I think it likely clutters the screen with more information. It's useful information and should be available for the full output format and for the templating but I'm not sure it should be included in the default docker ps output.

@vvoland
Copy link
Collaborator

vvoland commented Feb 10, 2025

Yeah I agree that this probably shouldn't be the default. I'd say that running containers with a non-native platform is not the common case, so that would just show extra information that's not relevant most of the time.

@thaJeztah
Copy link
Member

I've been contemplating adding a --tree to docker ps so that we can keep the default columns limited to "most essential", while still having access to more detailed information (such as platform, image-digest, labels, networks).

With some of the badges added in docker image ls, we could show something about "non-native" platform in the output though (but without that meaning "print the whole platform string")

@jsternberg
Copy link
Contributor Author

I'm going to close this because I think there's an agreement that this information shouldn't be included by default. It will be available through the format option or the JSON endpoint when moby/moby#49407 is merged.

@jsternberg jsternberg closed this Feb 13, 2025
@jsternberg jsternberg deleted the docker-ps-platform branch February 13, 2025 21:25
Comment on lines +216 to +224
// Platform returns a human-readable representation of the platform
// of the container if it is available.
func (c *ContainerContext) Platform() *container.ImagePlatform {
if c.c.Platform != nil {
return c.c.Platform
}
return &container.ImagePlatform{}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we still need this so the {{.Platform}} format works?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes was wondering the same and wanted to test.

@jsternberg TL;DR is that the "format" options don't act on the raw response from the API but use separate structs / (poorly named "context") types purely for formatting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured we'd probably want to avoid {{.Platform}} since it has a different meaning for the inspect response. I figure, since the data is there, we can always add an alias later when we've got a better idea of what we want. I can open a new PR though to add this alone if we can come up with something that makes sense.

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.

4 participants