testcontainers / testcontainers-go

Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.
https://golang.testcontainers.org
MIT License
3.3k stars 450 forks source link

[Bug]: v0.31.0 failing due to docker type removed in docker/docker dependency #2583

Closed KrazyK786 closed 2 weeks ago

KrazyK786 commented 2 weeks ago

Testcontainers version

0.31.0

Using the latest Testcontainers version?

Yes

Host OS

MacOS

Host arch

ARM64

Go version

1.22.3

Docker version

Client:
 Cloud integration: v1.0.35+desktop.13
 Version:           26.1.1
 API version:       1.45
 Go version:        go1.21.9
 Git commit:        4cf5afa
 Built:             Tue Apr 30 11:44:56 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.30.0 (149282)
 Engine:
  Version:          26.1.1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       ac2de55
  Built:            Tue Apr 30 11:48:04 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.31
  GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker info

Client:
 Version:    26.1.1
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0-desktop.1
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0-desktop.2
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.29
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-debug
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.23
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.1.0
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.8.0
    Path:     /Users/kristopherjohnson/.docker/cli-plugins/docker-scout

Server:
 Containers: 6
  Running: 0
  Paused: 0
  Stopped: 6
 Images: 43
 Server Version: 26.1.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e377cd56a71523140ca6ae87e30244719194a521
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.6.26-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 10
 Total Memory: 7.657GiB
 Name: docker-desktop
 ID: 71e08167-6ea6-4b63-ae72-0ac8f8d8e2a5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/kristopherjohnson/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

What happened?

Updated testcontainers package to latest:

go get -u github.com/testcontainers/testcontainers-go

Saw several dependencies update, including:

go: upgraded github.com/docker/docker v26.1.0+incompatible => v27.0.0+incompatible

Ran tests and received output in next section

Relevant log output

# github.com/testcontainers/testcontainers-go
../../go/pkg/mod/github.com/testcontainers/testcontainers-go@v0.31.0/docker.go:308:63: undefined: types.ImageRemoveOptions
../../go/pkg/mod/github.com/testcontainers/testcontainers-go@v0.31.0/docker.go:1071:21: undefined: types.ImagePullOptions
../../go/pkg/mod/github.com/testcontainers/testcontainers-go@v0.31.0/docker.go:1292:92: undefined: types.ImagePullOptions
../../go/pkg/mod/github.com/testcontainers/testcontainers-go@v0.31.0/docker.go:1431:3: unknown field CheckDuplicate in struct literal of type "github.com/docker/docker/api/types/network".CreateOptions
../../go/pkg/mod/github.com/testcontainers/testcontainers-go@v0.31.0/docker.go:1433:19: cannot use req.EnableIPv6 (variable of type bool) as *bool value in struct literal
../../go/pkg/mod/github.com/testcontainers/testcontainers-go@v0.31.0/docker.go:1601:50: undefined: types.ImageListOptions
../../go/pkg/mod/github.com/testcontainers/testcontainers-go@v0.31.0/docker.go:1644:48: undefined: types.ImagePullOptions

Additional information

Docker confirmed in this issue that v27.0.0 is a release candidate version accidentally tagged as a full version and that they should be releasing the actual full version (v27.0.1) sometime next week. With the errors given and the fact that the version is still a candidate for release, wanted to give testcontainers a heads up in case these changes are permanent.

Also, thank you for your amazing package!! It has been a blessing on our team and we truly appreciate all the effort the people behind this put in 🙇🏾

thaJeztah commented 2 weeks ago

Hm. I think those types were marked as deprecated since v26.0.0, which added temporary aliases to point to the new location; https://github.com/moby/moby/blob/v26.0.0/api/types/types_deprecated.go#L7-L35 (and those are removed with the v27.xx release

@mdelapenya do you know if there's a linter in this repository that would check for those deprecations?

thaJeztah commented 2 weeks ago

Ah, looks like this repo depends on v25.0.0, so yes, updating to two major versions ahead is somewhat expected to break things; https://github.com/testcontainers/testcontainers-go/blob/5d68a528f263685c8183e11e2a842f76926a1a28/go.mod#L10

I guess we can update it to v26.1, and adjust the code

mdelapenya commented 2 weeks ago

@thaJeztah thanks for checking. Indeed, I'm going to bump docker version to v26.1 then.

thaJeztah commented 2 weeks ago

I have a branch; pushing a PR now 😄

thaJeztah commented 2 weeks ago

@mdelapenya https://github.com/testcontainers/testcontainers-go/pull/2584