Exception looks like this:
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (http://localhost:59262/mockserver/status should return HTTP [200])
Suppose you want to start mockserver docker image on Mac M1. Probably you doing something like this:
DockerImageName containerImage = DockerImageName.parse("mockserver/mockserver:latest");
MockServerContainer container = MockServerContainer(containerImage)
.withExposedPorts(8080);
Most likely this error happens because of poor docker x86-64 image compatibility with the ARM (M1) CPU architecture.
If you see carefully, then you can find out that some versions of mockserver images (including latest sometimes) may not contain arm-specific image. See https://hub.docker.com/layers/mockserver/mockserver/mockserver-5.13.0/images/sha256-858f26f107c4fa385b9785a719d9fd333bb9cb4d3e6c88fe342822762d334cfd?context=explore, for example.
I suggest you to switch to image version 5.15.0, for example. It has arm-specific build:
DockerImageName containerImage = DockerImageName.parse("mockserver/mockserver:5.15.0");
MockServerContainer container = MockServerContainer(containerImage)
.withExposedPorts(8080);
Additional thanks:
- https://github.com/mock-server/mockserver/issues/819
- https://github.com/testcontainers/testcontainers-java/issues/4694
Telegram channel
If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.
If I saved your day, you can support me 🤝