Skip to content

fix(dockerclient): version API requests when no API version was configured - #862

Open
Eljees wants to merge 1 commit into
slimtoolkit:masterfrom
Eljees:fix/646-version-docker-api-requests
Open

Eljees wants to merge 1 commit into
slimtoolkit:masterfrom
Eljees:fix/646-version-docker-api-requests

Conversation

@Eljees

@Eljees Eljees commented Sep 22, 2026

Copy link
Copy Markdown

Fixes #646

Root cause

When the caller leaves DOCKER_API_VERSION / config.APIVersion empty (the common case for a plain slim build with no explicit override), dockerclient.New() builds a *docker.Client whose internal requestedAPIVersion field is never populated, so every outgoing request omits the /vX.Y/ path segment.

A daemon reached through a proxy - dind (Docker-in-Docker), the topology behind Bitbucket/GitLab self-hosted CI runners - reads an unversioned request as coming from the oldest client it supports and rejects it with client version ... is too old, exactly as reported in #646.

This is the same underlying bug as mintoolkit/mint#95 (dockerclient.New() here uses the same docker.NewVersionedClient(config.Host, config.APIVersion) + "SkipServerVersionCheck = true only when config.APIVersion != """ pattern), already fixed there in mintoolkit/mint#198.

Fix

Add newVersionedClient(), which probes the daemon's real API version with an initial Version() call and rebuilds the client with that version when the caller did not set one explicitly - the same effect as the caller setting DOCKER_API_VERSION by hand. Both call sites in New() now go through it.

Testing

Added TestNewClientDefaultAPIVersion_Issue646, which stands up a fake Docker daemon with httptest.Server and asserts the request path carries a version segment even when config.APIVersion was left empty.

Signed-off-by: Eljees 3.14hell@gmail.com

…gured

When the caller leaves DOCKER_API_VERSION / config.APIVersion empty
(the common case for a plain "slim build" with no explicit override),
dockerclient.New() builds a *docker.Client whose internal
requestedAPIVersion field is never populated, so every outgoing
request omits the "/vX.Y/" path segment.

A daemon reached through a proxy - dind (Docker-in-Docker), the
topology behind Bitbucket/GitLab self-hosted CI runners - reads an
unversioned request as coming from the oldest client it supports and
rejects it with "client version ... is too old", exactly as reported
in slimtoolkit#646.

Add newVersionedClient(), which probes the daemon's real API version
with an initial Version() call and rebuilds the client with that
version when the caller did not set one explicitly - the same effect
as the caller setting DOCKER_API_VERSION by hand. Both call sites in
New() now go through it.

Adds a regression test that stands up a fake Docker daemon and checks
that dockerclient.New()'s client sends a versioned request path even
when config.APIVersion was left empty.

Fixes slimtoolkit#646

Signed-off-by: Eljees <3.14hell@gmail.com>
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.

dockerutil.BuildEmptyImage() fails with bad API version

1 participant