-
Notifications
You must be signed in to change notification settings - Fork 2k
docker ps: add "Platform" as formatting option #6042
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
docker ps: add "Platform" as formatting option #6042
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6042 +/- ##
=======================================
Coverage 55.02% 55.03%
=======================================
Files 361 361
Lines 30131 30140 +9
=======================================
+ Hits 16581 16588 +7
- Misses 12595 12597 +2
Partials 955 955 🚀 New features to boost your workflow:
|
f1b444d
to
0441757
Compare
cli/command/formatter/container.go
Outdated
|
||
func (p Platform) String() string { | ||
if p.Platform.OS == "" { | ||
// Prevent rendering as "unknown" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't "unknown" actually make sense here if the platform isn't known?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... maybe yes. I think I did this because the platform could either be missing in the response or empty, but yeah, perhaps we could.
0441757
to
ef49b5d
Compare
7c82cc2
to
159c2df
Compare
cli/command/formatter/container.go
Outdated
// if p == nil || p.Platform == nil || (p.Platform.OS == "" && p.Platform.Architecture == "") { | ||
if p == nil || p.Platform == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBD: do we want a nil
platform and "zero" platform to be shown as nil
, or keep it as-is to distinguish both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A case where ImageManifestDescriptor.Platform
would be nil is unexpected:
https://github.com/moby/moby/blob/master/container/view.go#L419-L425
IMO, as this is user facing string, it would be appropriate to use the unknown
platform.
WDYT?
159c2df
to
b5f1a2b
Compare
@vvoland @Benehiko ptal; it's currently 3 separate commits, but should be squashed; I wasn't sure which if the approaches made most sense; make it use a pointer so that it can have |
I don't have a strong preference, returning |
docker ps --format 'table {{.ID}}\t{{.Image}}{{.Command}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}\t{{.Platform}}' CONTAINER ID IMAGECOMMAND CREATED STATUS PORTS NAMES PLATFORM e422855eac55 docker-cli-dev"/bin/bash" 12 minutes ago Up 12 minutes strange_jennings linux/arm64 Signed-off-by: Jonathan A. Sternberg <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
With this patch: docker ps --format 'table {{.Names}}\t{{.Platform}}' NAMES PLATFORM optimistic_nightingale linux/arm64 mycontainer linux/arm64/v8 trusting_goldstine linux/arm64 docker ps --format '{{.Platform}}' linux/arm64 linux/arm64/v8 linux/arm64 docker ps --format '{{json .Platform}}' {"architecture":"arm64","os":"linux"} {"architecture":"arm64","os":"linux","variant":"v8"} {"architecture":"arm64","os":"linux"} docker ps --format 'json' {"Command":"\"/bin/bash\"","CreatedAt":"2025-05-13 10:12:19 +0000 UTC","ID":"e8b3b2d604f1","Image":"docker-cli-dev","Labels":"desktop.docker.io/binds/0/Source=/Users/thajeztah/go/src/github.com/docker/cli,desktop.docker.io/binds/0/SourceKind=hostFile,desktop.docker.io/binds/0/Target=/go/src/github.com/docker/cli,desktop.docker.io/mounts/0/Source=/var/run/docker.sock,desktop.docker.io/mounts/0/SourceKind=dockerSocketProxied,desktop.docker.io/mounts/0/Target=/var/run/docker.sock,desktop.docker.io/ports.scheme=v2","LocalVolumes":"1","Mounts":"/host_mnt/User…,docker-cli-dev…,/run/host-serv…","Names":"optimistic_nightingale","Networks":"bridge","Platform":{"architecture":"arm64","os":"linux"},"Ports":"","RunningFor":"38 minutes ago","Size":"0B","State":"running","Status":"Up 38 minutes"} {"Command":"\"/docker-entrypoint.…\"","CreatedAt":"2025-05-13 09:58:01 +0000 UTC","ID":"c93b808dd54e","Image":"nginx:alpine","Labels":"desktop.docker.io/ports.scheme=v2,maintainer=NGINX Docker Maintainers \[email protected]\u003e","LocalVolumes":"0","Mounts":"","Names":"mycontainer","Networks":"bridge","Platform":{"architecture":"arm64","os":"linux","variant":"v8"},"Ports":"80/tcp","RunningFor":"53 minutes ago","Size":"0B","State":"running","Status":"Up 53 minutes"} {"Command":"\"/usr/bin/gotty --ti…\"","CreatedAt":"2025-05-13 07:31:18 +0000 UTC","ID":"cbb981b06e46","Image":"thajeztah/dockershell:latest","Labels":"desktop.docker.io/ports.scheme=v2,com.thajeztah.docker-shell=1","LocalVolumes":"0","Mounts":"","Names":"trusting_goldstine","Networks":"bridge","Platform":{"architecture":"arm64","os":"linux"},"Ports":"0.0.0.0:55000-\u003e8080/tcp","RunningFor":"3 hours ago","Size":"0B","State":"running","Status":"Up 3 hours"} Signed-off-by: Sebastiaan van Stijn <[email protected]>
b5f1a2b
to
67c0be4
Compare
@vvoland updated to squash the last 2 commits; PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
- What I did
- How I did it
- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)