dockertest
dockertest copied to clipboard
Client version too old error
Preflight checklist
- [x] I could not find a solution in the existing issues, docs, nor discussions.
- [x] I agree to follow this project's Code of Conduct.
- [x] I have read and am following this repository's Contribution Guidelines.
- [ ] I have joined the Ory Community Slack.
- [ ] I am signed up to the Ory Security Patch Newsletter.
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
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. .