javaspring-boottestcontainers

How to solve "Can't get Docker image" when using test containers?


I am using test containers and it used to work fine until now. I recently updated docker and IntelliJ, but I do not know if this is the cause of the following issue.

This are the dependencies I used:

testCompile 'org.testcontainers:testcontainers:1.12.3'
testCompile 'org.testcontainers:oracle-xe:1.12.3'

This is the stacktrace:

2020-10-12T13:13:06.709 WARN  testcontainers-ryuk [rg.testcontainers.utility.ResourceReaper]  - Can not connect to Ryuk at localhost:32778
java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:211)
    at org.testcontainers.utility.ResourceReaper.lambda$start$1(ResourceReaper.java:114)
    at java.lang.Thread.run(Thread.java:748)

java.lang.ExceptionInInitializerError
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    ...
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=ryangoh/oracle_12c_r1_xe:latest)
    at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1153)
    at org.testcontainers.containers.GenericContainer.setDockerImageName(GenericContainer.java:1141)
    at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:246)
    at org.testcontainers.containers.JdbcDatabaseContainer.<init>(JdbcDatabaseContainer.java:36)
    at org.testcontainers.containers.OracleContainer.<init>(OracleContainer.java:40)
    at com.vocalink.bps.reporting.integration.AbstractContainerTest.<clinit>(AbstractContainerTest.java:24)
    ... 49 more
Caused by: java.lang.IllegalStateException: Can not connect to Ryuk
    at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:150)
    at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:131)
    at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:51)
    at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:27)
    at org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:20)
    at org.testcontainers.utility.LazyFuture.get(LazyFuture.java:27)
    at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1151)
    ... 54 more

Does anyone know how to solve this issue?

Thank you in advance.


Solution

  • The issue was caused by the new docker version. In case you updated docker to 2.4.0 then there are a few options you can try.

    1. switch the "Use gRPC FUSE for file sharing" option off in docker preferences.
    2. update the testcontainers to 1.15.0-rc2
    3. downgrade docker to 2.3.x

    I tried the first option and it worked for me.

    I use a mac. I do not know if there is a similar issue on other platforms.