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

use RFC3339 CreatedAt time format in docker compose ps --format=json output #12520

Open
trim21 opened this issue Feb 2, 2025 · 3 comments
Open

Comments

@trim21
Copy link

trim21 commented Feb 2, 2025

Description

Description

Normally in json we use RFC3339(Nano) time format in json but in current output of json output it's "CreatedAt":"2025-02-02 08:40:17 +0000 UTC", which is a very "strange" format.

Steps To Reproduce

No response

Compose Version

Docker Compose version v2.28.1

Docker Environment


Anything else?

how to do this:

diff --git a/cmd/formatter/container.go b/cmd/formatter/container.go
index f1eb47caf5..13e7708560 100644
--- a/cmd/formatter/container.go
+++ b/cmd/formatter/container.go
@@ -183,7 +183,7 @@ func (c *ContainerContext) Command() string {
 }
 
 func (c *ContainerContext) CreatedAt() string {
-	return time.Unix(c.c.Created, 0).String()
+	return time.Unix(c.c.Created, 0).Format(time.RFC3339Nano)
 }
 
 func (c *ContainerContext) RunningFor() string {
@ndeloof
Copy link
Contributor

ndeloof commented Feb 3, 2025

We use the same formater as docker/cli for consistency
https://github.com/docker/cli/blob/master/cli/command/formatter/container.go#L199

This is used targeting a human reader, not adequate for json output indeed.

Changing this would be a backward compatibility break and require synchronous change in both docker/cli and compose. I guess this would be risky for a minimal benefits.

@trim21
Copy link
Author

trim21 commented Feb 4, 2025

sorry, I'm only proposaling to change format in json output but not outout in docker/cli or table format.

The example patch may change output of text format but that's my mistake, I'm not proposing to change anything except json output.

@ndeloof
Copy link
Contributor

ndeloof commented Feb 4, 2025

sure, but this is still a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants