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
The Docker image
mongo:3.6.0
has noarm64
built:Can you manually override the Docker image to
mongo:3.6.23
? That should work as this image comes witharm64
support.This worked on my M1 Max Macbook pro, you just have to add an extra dependency with the following version
There is apparently a library that older versions of
testcontainers
uses that Apple M1 chips aren’t compatible with. This causedContainerBasedTestsInitializer
to not find/run a docker container. Upgradingtestcontainers
to version1.16.3
worked for me.