try (GenericContainer<?> genericContainer = new GenericContainer<>("alpine:3.7")) {
genericContainer
.withCommand("false") // exit quickly
.withExposedPorts(1234)
.waitingFor(Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(1000)))
.start(); // should fail quickly
}
Observed
Waiting for exposed port takes 1000s
Expected
Stop waiting for port, since container is exited.
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8eb2b690815 alpine:3.7 "false" About a minute ago Exited (1) About a minute ago gifted_northcutt
e9ce5b30960c quay.io/testcontainers/ryuk:0.2.3 "/app" About a minute ago Up About a minute 0.0.0.0:33383->8080/tcp testcontainers-ryuk-7cf21936-f4ce-49ac-9ab8-6d278dcb07c0
Observed
Waiting for exposed port takes 1000s
Expected
Stop waiting for port, since container is
exited.