Testcontainers URL timeout M1


What's inside this article ⌄
  • Testcontainers mockserver M1 Mac
  • Testcontainers URL timeout fix
  • Mockserver Apple Silicon compatibility
  • Testcontainers M1 Mac error

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’re 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 this Docker image, for example.

I suggest that you 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);

Explore this link for a Docker image.

Additional links: