dockertest icon indicating copy to clipboard operation
dockertest copied to clipboard

Client version too old error

Open maggie44 opened this issue 3 months ago • 1 comments

Preflight checklist

Ory Network Project

No response

Describe the bug

When running BuildAndRunWithBuildOptions the following error is produced:

API error (400): client version 1.21 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

Reproducing the bug

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/ory/dockertest/v3"
	"github.com/ory/dockertest/v3/docker"
)

func main() {
	// Create pool (docker client)
	pool, err := dockertest.NewPool("")
	if err != nil {
		log.Fatalf("failed to connect to docker: %v", err)
	}

	// Attempt build+run with minimal Dockerfile context
	const contextDir = "." // adjust to a dir containing a Dockerfile

	res, err := pool.BuildAndRunWithBuildOptions(
		&dockertest.BuildOptions{
			ContextDir: contextDir,
			Dockerfile: "Dockerfile",
			Version:    "2",
		},
		&dockertest.RunOptions{
			NetworkID:    net.ID,
			ExposedPorts: []string{"8080/tcp"},
		},
		func(hc *docker.HostConfig) {
			hc.RestartPolicy = docker.RestartPolicy{Name: "no"}
		},
	)

	if err != nil {
		log.Printf("failed to build+start container: %v", err)
		return
	}
	defer pool.Purge(res)

	fmt.Println("container started successfully")
}

Relevant log output


Relevant configuration


Version

v3.12.0

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker

Additional Context

No response

maggie44 avatar Sep 12 '25 16:09 maggie44

This works ok. Seems like the default version just needs bumping:

	client, err := docker.NewVersionedClient(opts.DefaultHost, "1.25")
	if err != nil {
		return 1
	}

	pool := &dockertest.Pool{
		Client: client,
	}

Ideally we would be able to pass in a version as an option for future compatibility. .

maggie44 avatar Sep 12 '25 16:09 maggie44