英文:
How to solve "Can't get Docker image" when using test containers?
问题
以下是翻译好的部分:
我正在使用测试容器,之前一直都很正常,但最近更新了Docker和IntelliJ,但我不知道这是否是下面问题的原因。
这是我使用的依赖项:
testCompile 'org.testcontainers:testcontainers:1.12.3'
testCompile 'org.testcontainers:oracle-xe:1.12.3'
这是堆栈跟踪:
2020-10-12T13:13:06.709 WARN testcontainers-ryuk [org.testcontainers.utility.ResourceReaper] - 无法连接到Ryuk,地址为localhost:32778
java.net.ConnectException: 连接被拒绝
at java.net.PlainSocketImpl.socketConnect(Native Method)
...
java.lang.ExceptionInInitializerError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
由于:org.testcontainers.containers.ContainerFetchException: 无法获取Docker镜像:RemoteDockerImage(imageName=ryangoh/oracle_12c_r1_xe:latest)
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1153)
...
导致 java.lang.IllegalStateException: 无法连接到Ryuk
at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:150)
...
是否有人知道如何解决这个问题?
提前谢谢您。
英文:
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.
答案1
得分: 9
问题是由新的 Docker 版本引起的。如果你将 Docker 更新到 2.4.0,那么有几个选项可以尝试。
- 在 Docker 首选项中关闭“使用 gRPC FUSE 进行文件共享”选项。
- 将 testcontainers 更新到 1.15.0-rc2 版本。
- 将 Docker 降级到 2.3.x 版本。
我尝试了第一个选项,对我起作用了。
我使用的是 Mac。我不知道其他平台是否存在类似的问题。
英文:
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.
- switch the "Use gRPC FUSE for file sharing" option off in docker preferences.
- update the testcontainers to 1.15.0-rc2
- 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论