testcontainers-java
testcontainers-java copied to clipboard
[Bug]: Error while creating mount source path (/host_mnt/Users/_user/.docker/run/docker.sock): operation not supported
Module
Core
Testcontainers version
1.13.0
Using the latest Testcontainers version?
Yes
Host OS
MacOS Sonoma 14.1
Host Arch
ARM64
Docker version
Client:
Cloud integration: v1.0.35+desktop.5
Version: 24.0.7
API version: 1.43
Go version: go1.20.10
Git commit: afdd53b
Built: Thu Oct 26 09:04:20 2023
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.26.1 (131620)
Engine:
Version: 24.0.7
API version: 1.43 (minimum version 1.12)
Go version: go1.20.10
Git commit: 311b9ff
Built: Thu Oct 26 09:08:15 2023
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.25
GitCommit: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
runc:
Version: 1.1.10
GitCommit: v1.1.10-0-g18a0cb0
docker-init:
Version: 0.19.0
GitCommit: de40ad0
What happened?
Testcontainer runs into an error when starting container.
Caused by: com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"error while creating mount source path '/host_mnt/Users/_user/.docker/run/docker.sock': mkdir /host_mnt/Users/_user/.docker/run/docker.sock: operation not supported"}
Relevant log output
Connected to the target VM, address: '127.0.0.1:52875', transport: 'socket'
2024-01-29 14:48:25,001 INFO [main]- at o.t.d.DockerClientProviderStrategy::lambda$getFirstValidStrategy$1(DockerClientProviderStrategy.java:110) Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first |TAGS|
2024-01-29 14:48:25,335 INFO [main]- at o.t.d.UnixSocketClientProviderStrategy::test(UnixSocketClientProviderStrategy.java:37) Accessing docker with local Unix socket |TAGS|
2024-01-29 14:48:25,335 INFO [main]- at o.t.d.DockerClientProviderStrategy::lambda$getFirstValidStrategy$2(DockerClientProviderStrategy.java:119) Found Docker environment with local Unix socket (unix:///var/run/docker.sock) |TAGS|
2024-01-29 14:48:25,398 INFO [main]- at o.t.DockerClientFactory::client(DockerClientFactory.java:137) Docker host IP address is localhost |TAGS|
2024-01-29 14:48:25,427 INFO [main]- at o.t.DockerClientFactory::client(DockerClientFactory.java:144) Connected to docker:
Server Version: 24.0.7
API Version: 1.43
Operating System: Docker Desktop
Total Memory: 15982 MB |TAGS|
org.testcontainers.containers.ContainerLaunchException: Container startup failed
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:322)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:302)
at org.testcontainers.couchbase.CouchbaseContainer.startProxy(CouchbaseContainer.java:156)
at org.testcontainers.couchbase.CouchbaseContainer.doStart(CouchbaseContainer.java:134)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:302)
at com.company.messaging.async.auto.systemtests.general.CouchbaseContainerManager.getInstance(CouchbaseContainerManager.java:69)
at com.company.messaging.async.auto.systemtests.general.CouchbaseContainerManager.setUp(CouchbaseContainerManager.java:89)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageNameFuture=java.util.concurrent.CompletableFuture@74075134[Completed normally], imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE)
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1265)
at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:600)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:311)
... 8 more
Caused by: com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"error while creating mount source path '/host_mnt/Users/_user/.docker/run/docker.sock': mkdir /host_mnt/Users/_user/.docker/run/docker.sock: operation not supported"}
at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.execute(OkHttpInvocationBuilder.java:287)
at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.execute(OkHttpInvocationBuilder.java:265)
at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.post(OkHttpInvocationBuilder.java:126)
at com.github.dockerjava.core.exec.StartContainerCmdExec.execute(StartContainerCmdExec.java:28)
at com.github.dockerjava.core.exec.StartContainerCmdExec.execute(StartContainerCmdExec.java:11)
at com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
at com.github.dockerjava.core.command.StartContainerCmdImpl.exec(StartContainerCmdImpl.java:46)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testcontainers.dockerclient.AuditLoggingDockerClient.lambda$wrappedCommand$14(AuditLoggingDockerClient.java:99)
at jdk.proxy2/jdk.proxy2.$Proxy29.exec(Unknown Source)
at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:94)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:155)
at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)
at org.testcontainers.LazyDockerClient.listImagesCmd(LazyDockerClient.java:12)
at org.testcontainers.images.LocalImagesCache.maybeInitCache(LocalImagesCache.java:68)
at org.testcontainers.images.LocalImagesCache.get(LocalImagesCache.java:32)
at org.testcontainers.images.AbstractImagePullPolicy.shouldPull(AbstractImagePullPolicy.java:18)
at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:62)
at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:25)
at org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:20)
at org.testcontainers.utility.LazyFuture.get(LazyFuture.java:27)
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1263)
... 10 more
Test ignored.
Disconnected from the target VM, address: '127.0.0.1:52875', transport: 'socket'
Process finished with exit code 255
Additional Information
No response
Testcontainers version used is an old version and it was demonstrated that the setup works perfectly fine using testcontainers-java-repro and Docker Desktop. There are so many changes between 1.13.0 and 1.19.4. Also, the couchbase container implementation is different.
The following suggestion. Check Settings > Advanced > Allow the default Docker socket to be used (requires password)
didn't work.
I'm also facing the error when I'm using latest version of test container with spring boot 3.2
I did not face the issue until yesterday when I ran the test
through gradle except intellij. Now I'm facing the same issue when I ran it through gradle
through command line as well.
Same issue here, as described by @ganesanarun
Can you share a project that reproduces the issue, please?
You can fix this by setting these properties.
Use docker context ls
to get your docker endpoint.
For example, unix:///Users/<user>/.docker/run/docker.sock
.
Then do these 3 things.
export DOCKER_HOST=unix:///Users/<user>/.docker/run/docker.sock
ln -sf /Users/<user>/.docker/run/docker.sock /var/run/docker.sock
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
That is how I got around this. Unfortunately, you can not just set TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
to /Users/<user>/.docker/run/docker.sock
, it needs to point to the sym link (not sure why).
That should solve this issue, at least it did for me.
I hit this issue on an older project using testcontainers 1.18.x. Tests were working before, the only recent changes were upgrades to MacOS and colima. Upgrading to 1.19.8 solved the issue for me. My setup:
- MacOS Sonoma 14.5
- colima 0.6.9, installed through homebrew
The workaround does not work if you don't have root access on OSX.
What is suggested by @jlemay should work for old versions. New versions should discover the socket in different locations for Docker and Docker Desktop in macOS and linux. For other container runtimes there is no socket discovery but we have done our best to document was is needed here.