Skip to content

sys: notify client-server API version mismatch#7093

Open
maksimtech wants to merge 1 commit into
docker:masterfrom
maksimtech:fix-version-downgrade-log
Open

sys: notify client-server API version mismatch#7093
maksimtech wants to merge 1 commit into
docker:masterfrom
maksimtech:fix-version-downgrade-log

Conversation

@maksimtech

Copy link
Copy Markdown

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.

Signed-off-by: Massimo Moretti <github@maksimtech.com>

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)
...

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.

2 participants