I would like to run a container with testcontainers on a network. My containers contains a spring application, which has an actuator endpoint to express its state, it is on:
/actuator/health
My container looks like the following:
private final static Network network = Network.newNetwork();
private static final GenericContainer<?> myContainer = new GenericContainer<>("mycontainer:latest")
.withExposedPorts(8443)
.withNetwork(network)
.withNetworkAliases("myContainer")
.withClasspathResourceMapping("certs", "/app/certs", BindMode.READ_ONLY)
.withClasspathResourceMapping("config", "/app/config", BindMode.READ_ONLY)
.withLogConsumer(new Slf4jLogConsumer(log))
.waitingFor(Wait.forHttp("/actuator/health").usingTls());
But when i start this container I get the following error:
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (https://localhost:33092/actuator/health should return HTTP [200])
at org.testcontainers.containers.wait.strategy.HttpWaitStrategy.waitUntilReady(HttpWaitStrategy.java:214)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:890)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:441)
... 68 more
But if I curl this url (in this example: https://localhost:33092/actuator/health
) while after the application inside the container has started but I am waiting for the evaulation, I get something like this:
HTTP Status Code: 200
{
"status": "UP"
}
What am I missing? Any ideas? Is it a bug?