sys: notify client-server API version mismatch#7093
Conversation
Signed-off-by: Massimo Moretti <github@maksimtech.com>
thaJeztah
left a comment
There was a problem hiding this comment.
What problem are you trying to solve? The output already indicates if the client downgraded? e.g. when running a current version of the CLI against an old (23.x) daemon;
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock docker:cli version
Client:
Version: 29.6.1
API version: 1.42 (downgraded from 1.55)
Go version: go1.26.4
Git commit: 8900f1d
Built: Fri Jun 26 11:39:39 2026
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 23.0.4
API version: 1.42 (minimum version 1.12)
...|
Thanks for the review and for pointing that out! My main goal was to expose this event to Having a standardized stream notification on stderr allows automation tools to immediately catch that an API version session mismatch/downgrade occurred. That being said, if you feel this introduces unnecessary noise or redundancy, I completely understand and I'm happy to close the PR! |
Description
This PR adds an explicit notification log when the Docker CLI client session API version is downgraded to match the daemon (server) version.
Currently, when the client supports a higher API version than the daemon, it silently downgrades the session API version to maintain compatibility. While this fallback mechanism works flawlessly, providing a clear note in the docker version output helps developers and administrators immediately notice that a protocol downgrade has occurred.
Changes
Modified cli/command/system/version.go.
Added a conditional check inside runVersion after the ServerVersion API call to compare the client's supported API version with the negotiated server API version.
Prints a clear message to dockerCLI.Err() if a mismatch/downgrade is detected:
Note: API version session negotiated to (Client supports ).
How to test
Build the binary locally: make binary
Run the compiled docker binary against a Docker Daemon that has a lower API version than the client:
Bash
./build/docker version
Verify that the warning note appears dynamically above the standard prettyPrintVersion output.
Checklist
[x] I have signed my commits with git commit -s (DCO checked).
[x] The code builds successfully locally.