skip to Main Content

I’m trying to run Integration Tests on my local. I’m trying to pull mongo 3.6.0 image, I’m getting following errrors. The same thing is working on non-m1 mac.

ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$7 – UnixSocketClientProviderStrategy: failed with exception RuntimeException (java.lang.UnsatisfiedLinkError: /private/var/folders/88/zxy8rm992j10d7_db5w5w2580000gq/T/jna–714400992/jna3748287117789473831.tmp: dlopen(/private/var/folders/88/zxy8rm992j10d7_db5w5w2580000gq/T/jna–714400992/jna3748287117789473831.tmp, 0x0001): tried: ‘/private/var/folders/88/zxy8rm992j10d7_db5w5w2580000gq/T/jna–714400992/jna3748287117789473831.tmp’ (fat file, but missing compatible architecture (have ‘i386,x86_64’, need ‘arm64e’)), ‘/usr/lib/jna3748287117789473831.tmp’ (no such file)). Root cause UnsatisfiedLinkError
(/private/var/folders/88/zxy8rm992j10d7_db5w5w2580000gq/T/jna–714400992/jna3748287117789473831.tmp: dlopen(/private/var/folders/88/zxy8rm992j10d7_db5w5w2580000gq/T/jna–714400992/jna3748287117789473831.tmp, 0x0001): tried: ‘/private/var/folders/88/zxy8rm992j10d7_db5w5w2580000gq/T/jna–714400992/jna3748287117789473831.tmp’ (fat file, but missing compatible architecture (have ‘i386,x86_64’, need ‘arm64e’)), ‘/usr/lib/jna3748287117789473831.tmp’ (no such file))

Can’t get Docker image: RemoteDockerImage(imageName=mongo:3.6.0, imagePullPolicy=DefaultPullPolicy())
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1278)
at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:612)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:317)
… 74 more
Caused by: java.lang.IllegalStateException: Previous attempts to find a Docker environment failed. Will not retry. Please see logs and check configuration
at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:108)
at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:134)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:176)
at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)
at org.testcontainers.LazyDockerClient.inspectImageCmd(LazyDockerClient.java:12)
at org.testcontainers.images.LocalImagesCache.refreshCache(LocalImagesCache.java:42)
at org.testcontainers.images.AbstractImagePullPolicy.shouldPull(AbstractImagePullPolicy.java:24)
at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:66)
at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:27)
at org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:17)
at org.testcontainers.utility.LazyFuture.get(LazyFuture.java:39)
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1276)

i’ve following non root user configuration in my docker file

#Non Root User Configuration
RUN addgroup -S -g 10001 appGrp
&& adduser -S -D -u 10000 -s /sbin/nologin -h /opt/app/ -G appGrp app
&& chown -R 10000:10001 /opt/app
USER 10000

3

Answers


  1. The Docker image mongo:3.6.0 has no arm64 built:

    enter image description here

    Can you manually override the Docker image to mongo:3.6.23? That should work as this image comes with arm64 support.

    Login or Signup to reply.
  2. This worked on my M1 Max Macbook pro, you just have to add an extra dependency with the following version

            <dependency>
                <groupId>net.java.dev.jna</groupId>
                <artifactId>jna</artifactId>
                <version>5.7.0</version>
                <scope>test</scope>
            </dependency>
    
    Login or Signup to reply.
  3. There is apparently a library that older versions of testcontainers uses that Apple M1 chips aren’t compatible with. This caused ContainerBasedTestsInitializer to not find/run a docker container. Upgrading testcontainers to version 1.16.3 worked for me.

    <testcontainers.version>1.16.3</testcontainers.version>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search