Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot connect to ryuk when running test inside docker container #1373

Open
n-tucker opened this issue Jul 31, 2023 · 4 comments
Open
Labels
bug An issue with the library

Comments

@n-tucker
Copy link

Testcontainers version

0.21.0

Using the latest Testcontainers version?

Yes

Host OS

Mac

Host arch

ARM

Go version

1.20.3

Docker version

Client:
 Cloud integration: v1.0.31
 Version:           23.0.5
 API version:       1.42
 Go version:        go1.19.8
 Git commit:        bc4487a
 Built:             Wed Apr 26 16:12:52 2023
 OS/Arch:           darwin/arm64
 Context:           default

Server: Docker Desktop 4.19.0 (106363)
 Engine:
  Version:          23.0.5
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       94d3ad6
  Built:            Wed Apr 26 16:17:14 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.3
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.19
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.4
    Path:     /Users/nicholas.tucker/.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/nicholas.tucker/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-scan
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  v0.10.0
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-scout

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 4
 Server Version: 23.0.5
 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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 7.765GiB
 Name: docker-desktop
 ID: 8c325c45-1e53-4780-b05a-1c44ddcd3d31
 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
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

What happened?

First of all, thank you for providing this package!

I've been trying to incorporate a testcontainers test in our CI platform. To do this, I'm attempting to run testcontainers within a docker container by running docker-outside-of-docker (as described in the docs here).

I'm encountering an issue where I'm having trouble connecting to reaper container within my golang container. I've been able to confirm that disabling ryuk allows my test to run as expected, however I'd like to understand if it's possible to get the automated reaping working?

Based off what I've understood, the reaper container is hard-coded to use a bridge network and (not 100% confident) is also configured to create its own bridge network named reaper_default. Despite this, it appears that the reaper container should be configured with the default bridge network, so I'm a little bit stumped.

Thanks in advance for any guidance or help anyone can provide, and I'm happy to provide more info if required! 😄

Relevant log output

=== RUN   TestMain
2023/07/31 07:06:26 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 23.0.5
  API Version: 1.42
  Operating System: Docker Desktop
  Total Memory: 7951 MB
2023/07/31 07:06:26 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 23.0.5
  API Version: 1.42
  Operating System: Docker Desktop
  Total Memory: 7951 MB
2023/07/31 07:06:26 🐳 Creating container for image docker.io/testcontainers/ryuk:0.5.1
2023/07/31 07:06:26 ✅ Container created: 02c17f2f3f39
2023/07/31 07:06:26 🐳 Starting container: 02c17f2f3f39
2023/07/31 07:06:26 ✅ Container started: 02c17f2f3f39
2023/07/31 07:06:26 🚧 Waiting for container id 02c17f2f3f39 image: docker.io/testcontainers/ryuk:0.5.1. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
panic: test timed out after 30s
running tests:
        TestMain (30s)

goroutine 1017 [running]:
testing.(*M).startAlarm.func1()
        /usr/local/go/src/testing/testing.go:2241 +0x31c
created by time.goFunc
        /usr/local/go/src/time/sleep.go:176 +0x38

Additional information

No response

@paukul
Copy link

paukul commented Sep 18, 2023

@n-tucker have you tried setting TC_HOST to host.docker.internal? The documentation is wrongly asking to set TESTCONTAINERS_HOST_OVERRIDE but the go implementation works differently. There's a lengthy discussion currently in the testcontainers-go slack channel going on right now https://testcontainers.slack.com/archives/CBWBNR76G/p1694693291692039

Maybe this is totally unrelated, but at least your issue fits what I was experiencing, running testcontainers from within a vscode devcontainer. Setting TC_HOST fixed both running ryuk and the actual testcontainers for me

@arvenil
Copy link

arvenil commented Feb 12, 2024

I'm running into similar issue. I'm following https://golang.testcontainers.org/system_requirements/ci/gitlab_ci/#example-using-docker-socket and so far it doesn't seem to work. Is the TESTCONTAINERS_HOST_OVERRIDE variable implemented?

@mdelapenya
Copy link
Member

@arvenil I think you're right and the gitlab docs are outdated (I'm creating an issue for that now).

For the rest of you here, the docker host/socket resolution is properly documented here, including supported env vars that affect the Docker env discovery: https://golang.testcontainers.org/features/configuration/#docker-host-detection

At the same time, some improvements regarding Ryuk and how it's spawned has been added in the recent versions, I'd ask you to verify if possible if this behaviour happens with the recent releases (0.27.0 and main) 🙏

@mdelapenya
Copy link
Member

Could you try the latest v0.33.0 release? I had a user having this issue that was fixed for them with the latest release 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

No branches or pull requests

4 participants