28

I am using test containers library to launch a container. It worked for a while but currently running into this

java.lang.IllegalStateException: Could not connect to Ryuk at localhost:49167

    at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:201)
    at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:205)
    at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)
    at org.testcontainers.LazyDockerClient.authConfig(LazyDockerClient.java:12)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:310)

I looked at the resource reaper code and it seems like it is failing here

public synchronized void performCleanup() {
    this.registeredContainers.forEach(this::stopContainer);
    this.registeredNetworks.forEach(this::removeNetwork); //FAILS HERE
    this.registeredImages.forEach(this::removeImage);
}
mchernyakov
  • 196
  • 3
  • 14
user1870400
  • 6,028
  • 13
  • 54
  • 115

7 Answers7

14

I tried everything mentioned here but nothing worked.

If anyone is still facing the issue they can give this one a try... this worked for me.

This works for windows:

  1. open you PowerShell in administrator mode.
  2. run net stop winnat
  3. run net start winnat

Doing this resolved this issue on my setup. Hope this helps someone.

zforgo
  • 2,508
  • 2
  • 14
  • 22
Anmol moses
  • 143
  • 1
  • 3
12

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

Windows 10, Docker desktop 4.0.0

Olavi Vaino
  • 422
  • 5
  • 10
10

I ran into the same issue. Same Docker-for-Mac version.

Solution for me was to disable "Use gRPC FUSE for file sharing" in Preferences: Preferences

SiKing
  • 10,003
  • 10
  • 39
  • 90
user1650355
  • 109
  • 1
  • 3
9

For me, restarting the local docker engine solved the problem

KAD
  • 10,972
  • 4
  • 31
  • 73
1

I'm on a Windows 11 machine with the same issue:

It turned out that a vast number of ports were allocated by the service "IP helper" (relates to ipv6 support), i.e. ports prior allocated by testcontainers, or other services. They were allocated for weeks by Ip helper but never, or rarely, released. By permanently disabling service Ip helper all issues were resolved and the set-up works great since then without any observed side effects that I am in need of.

0

Setting: Windows11 + Rancher Desktop

Restarting Rancher Desktop did not help. However, restarting my computer did the job.

Shakesbeer
  • 71
  • 6
0

Setting: Windows11 + Rancher Desktop

For me was helpful this comment: https://github.com/testcontainers/testcontainers-java/issues/3609#issuecomment-769615098

In file testcontainer.properties at your user folder add:

ryuk.container.privileged=false

Set environment variable for your user:

TESTCONTAINERS_RYUK_DISABLED=true

cheparsky
  • 514
  • 6
  • 20