0

在我使用 testcontainers 进行的一项测试中,容器无法启动,日志为:

  [ERROR] 17:31:38,814 [Test worker] 1.1]. - Could not start container
     org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [49154, 49155, 49156, 49157] should be listening)
        at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:90) ~[testcontainers-1.16.2.jar:?]

但是,当我注意到启动容器需要很长时间时,我查看了容器状态:

CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS         PORTS                                                                                                                     NAMES
a9b52c87cf48   corda-four-nodes:0.1.1      "/bin/bash runnodes.…"   2 minutes ago   Up 2 minutes   10030-10033/tcp, 0.0.0.0:49157->10010/tcp, 0.0.0.0:49156->10011/tcp, 0.0.0.0:49155->10012/tcp, 0.0.0.0:49154->10013/tcp   nice_merkle
f1de539585cd   testcontainers/ryuk:0.3.3   "/app"                   2 minutes ago   Up 2 minutes   0.0.0.0:49153->8080/tcp                                                                                                   testcontainers-ryuk-69c9e72d-040b-4625-a82e-dbaf7d0a1cec

很明显端口10010-10013已经映射到49154-49157,使用netcat,这些端口是可达的,但是为什么会出现错误,无法启动容器呢?

容器定义:

    @Container
    @SuppressWarnings("rawtypes")
    public static GenericContainer network = new GenericContainer(DockerImageName.parse(IMAGE_NAME))
            .withFileSystemBind(getCordappPath(), "/nodes/Notary/cordapps", BindMode.READ_WRITE)
            .withFileSystemBind(getCordappPath(), "/nodes/PartyA/cordapps", BindMode.READ_WRITE)
            .withFileSystemBind(getCordappPath(), "/nodes/PartyB/cordapps", BindMode.READ_WRITE)
            .withFileSystemBind(getCordappPath(), "/nodes/PartyC/cordapps", BindMode.READ_WRITE)
            .withExposedPorts(10010, 10011, 10012, 10013)
            .withStartupTimeout(Duration.ofSeconds(180));

(绑定工作正常)

4

0 回答 0