如何解决在使用测试容器时出现的“无法获取Docker镜像”问题?

huangapple go评论69阅读模式
英文:

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,那么有几个选项可以尝试。

  1. 在 Docker 首选项中关闭“使用 gRPC FUSE 进行文件共享”选项。
  2. 将 testcontainers 更新到 1.15.0-rc2 版本。
  3. 将 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.

  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.

huangapple
  • 本文由 发表于 2020年10月12日 21:38:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/64319001.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定