question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Can not connect to Ryuk at 172.17.0.1:61798: Connection refused

See original GitHub issue

Module

Core

Testcontainers version

1.17.3

Using the latest Testcontainers version?

Yes

Host OS

Mac OS X

Host Arch

x86_64

Docker version

Client:
 Cloud integration: 1.0.17
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:55:20 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:10 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

Testcontainers is unable to connect to Ryuk after it starts. I would expect it to be able to connect and launch the additional containers.

Note I am using running tests using Testcontainers inside a Docker container on Mac OS. The Docker container runs a Maven build to run the tests. This same image to run the tests is used on the CI server which uses Linux (don’t know which flavor) and the build succeeds.

The command is essentially:

docker run -it --rm -u 0:0 -v /var/run/docker.sock:/var/run/docker.sock:ro -P -v ~/.m2/repository:/root/.m2/repository -v /Users/adamjshook/project:/Users/adamjshook/project -w /Users/adamjshook/project internal/ubuntu18-openjdk11-maven /bin/bash -c "mvn install"

Relevant log output

[main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with local Unix socket (unix:///var/run/docker.sock)
[main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is 172.17.0.1
[main] INFO org.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 20.10.8
  API Version: 1.41
  Operating System: Docker Desktop
  Total Memory: 16011 MB
[main] WARN org.testcontainers.utility.ConfigurationFileImageNameSubstitutor - Image name testcontainers/ryuk:0.3.3 was substituted by configuration to internal/ryuk:latest. This approach is deprecated and will be removed in the future
[main] INFO org.testcontainers.utility.ImageNameSubstitutor - Using internal/ryuk:latest as a substitute image for testcontainers/ryuk:0.3.3 (using image substitutor: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor'))
[main] INFO docker[internal/ryuk:latest] - Creating container for image: internal/ryuk:latest
[main] INFO org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config. Please ignore if you don't have images in an authenticated registry. Details: (dockerImageName: internal/ryuk:latest, configFile: /root/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /root/.docker/config.json (No such file or directory)
[main] INFO docker[internal/ryuk:latest] - Container internal/ryuk:latest is starting: 086f10a9ab6496f1cf4cab982890a69fbc09f86548a2e8bdd468ddbdb8416d5f
[main] INFO docker[internal/ryuk:latest] - Container internal/ryuk:latest started in PT1.337369S
[testcontainers-ryuk] WARN org.testcontainers.utility.RyukResourceReaper - Can not connect to Ryuk at 172.17.0.1:61798
java.net.ConnectException: Connection refused (Connection refused)
        at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
        at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.base/java.net.Socket.connect(Socket.java:609)
        at org.testcontainers.utility.RyukResourceReaper.lambda$null$0(RyukResourceReaper.java:92)
        at org.rnorth.ducttape.ratelimits.RateLimiter.doWhenReady(RateLimiter.java:27)
        at org.testcontainers.utility.RyukResourceReaper.lambda$maybeStart$1(RyukResourceReaper.java:88)
        at java.base/java.lang.Thread.run(Thread.java:829)

Additional Information

Setting TESTCONTAINERS_RYUK_DISABLED=true allows my test cases to pass. I do not experience this on previous version 1.15.3; the tests run as expected. I hit this issue starting in 1.16.0 and is still present in 1.16.3.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kiviewcommented, Sep 28, 2022

@adamjshook Unfortunately I don’t know what else we can do here, it probably requires more detailed debugging of the Docker environment. Did you verify that /var/run/docker.sock.raw exists and that you can interact with it?

Can you please share your finding, that the workaround does not work for you in #4395? I will close this issue as a duplicate.

1reaction
kiviewcommented, Sep 26, 2022

Testcontainers inside a Docker container on Mac OS

I think you are running into this upstream issue: https://github.com/testcontainers/testcontainers-java/issues/4395 Please try out the workaround specified here and let us know if it helps.

@hariohmprasath Thanks a lot for your supportt in triaging this issue 🙇

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not connect to Ryuk at localhost:49167 - Stack Overflow
I can confirm that this is resolved by updating testcontainers to 1.16.0 version. Was facing the same exception with testcontainers 1.15.3.
Read more >
Testcontainers stoped working | Bitbucket Cloud - Jira
Bug BCLOUD / BCLOUD-17236 ... ResourceReaper : Can not connect to Ryuk at localhost:32768 java.net.ConnectException: Connection refused (Connection refused).
Read more >
Gitlab runner dind service cannot be used with Testcontainers
ResourceReaper - Can not connect to Ryuk at 172.18.0.1:32768 java.net. ... mapped ports and connecting to them without networking issues.
Read more >
1758227 – SELinux is preventing app from connectto access ...
Description of problem: I'm trying to run a Java application that ... "Can not connect to Ryuk" Expected results: no selinux denial, ...
Read more >
Custom configuration - Testcontainers for Java
The configuration will be loaded from multiple locations. ... but does not allow starting privileged containers, you can turn off the Ryuk container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found