Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Nov 12, 2025

The client.ServerVersion method in the moby/client module defines an output struct that's separate from the API response. These output structs are not designed to be marshaled as JSON, but the CLI depended on them defining json labels, which it used to format the output as JSON (docker version --format=json); as a result, the JSON output changed in docker v29, as it would now use the naming based on the Go struct's fields (APIVersion instead of ApiVersion).

In future, we should consider having a --raw (or similar) option for the CLI to print API responses as-is, instead of using client structs or CLI structs for this (this would also make sure the JSON output does not inherit client-side formatting of fields).

For now, let's create a struct for formatting the output, similar to what we do for the client-side information.

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

Fix output format of the `ApiVersion` and `MinApiVersion` fields in  `docker version --format=json` to align with previous versions.

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

@thaJeztah thaJeztah added this to the 29.1.0 milestone Nov 12, 2025
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 12.19512% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/command/system/version.go 12.19% 35 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

The client.ServerVersion method in the moby/client module defines
an output struct that's separate from the API response. These output
structs are not designed to be marshaled as JSON, but the CLI depended
on them defining `json` labels, which it used to format the output
as JSON (`docker version --format=json`); as a result, the JSON output
changed in docker v29, as it would now use the naming based on the Go
struct's fields (`APIVersion` instead of `ApiVersion`).

In future, we should consider having a `--raw` (or similar) option for
the CLI to print API responses as-is, instead of using client structs
or CLI structs for this (this would also make sure the JSON output does
not inherit client-side formatting of fields).

For now, let's create a struct for formatting the output, similar to what
we do for the client-side information.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the cli_version_json_format branch from 736df9d to bff56f0 Compare November 12, 2025 13:57
@vvoland vvoland modified the milestones: 29.1.0, 29.0.1 Nov 12, 2025
Comment on lines +149 to +153
out.GitCommit = component.Details["GitCommit"]
out.GoVersion = component.Details["GoVersion"]
out.KernelVersion = component.Details["KernelVersion"]
out.Experimental = func() bool { b, _ := strconv.ParseBool(component.Details["Experimental"]); return b }()
out.BuildTime = reformatDate(component.Details["BuildTime"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

These were empty in 29.0.0. Is it intentional to restore them?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was on the fence on these; decided to keep the status quo (pre v29) for now, in case there's people depending on them after all but we should consider removing them.

@thaJeztah
Copy link
Member Author

OK, let's bring this one in 👍

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