Repository navigation
[Bug]: LocalStack doesn't start if Allow the default Docker socket to be used is unchecked #7678
Description
Module
LocalStack
Testcontainers version
1.19.1
Using the latest Testcontainers version?
Yes
Host OS
macos
Host Arch
ARM
Docker version
Client:
Version: 24.0.6-rd
API version: 1.43
Go version: go1.20.7
Git commit: da4c87c
Built: Wed Sep 6 16:40:13 2023
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.24.2 (124339)
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:31:36 2023
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0What happened?
LocalStackContainer doesn't start when Allow the default Docker socket to be used (requires password) option in Docker Desktop for Mac is unchecked.
In the following method:
testcontainers-java/core/src/main/java/org/testcontainers/DockerClientFactory.java
Lines 162 to 176 in 6e2b091
| public String getRemoteDockerUnixSocketPath() { | |
| if (this.strategy != null && this.strategy.allowUserOverrides()) { | |
| String dockerSocketOverride = System.getenv("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE"); | |
| if (!StringUtils.isBlank(dockerSocketOverride)) { | |
| return dockerSocketOverride; | |
| } | |
| } | |
| if (this.strategy != null && this.strategy.getRemoteDockerUnixSocketPath() != null) { | |
| return this.strategy.getRemoteDockerUnixSocketPath(); | |
| } | |
| URI dockerHost = getTransportConfig().getDockerHost(); | |
| String path = "unix".equals(dockerHost.getScheme()) ? dockerHost.getRawPath() : "/var/run/docker.sock"; | |
| return SystemUtils.IS_OS_WINDOWS ? "/" + path : path; | |
| } |
strategy is null. After calling getTransportConfig().gerDockerHost(), the strategy will contain the right values and the docker host to be used.
Let's take into account that currently, LocalStackContainer tries to mount the docker socket in the constructor and at this point no strategy has been discovered yet. The following line
Line 116 in f1b0b07
| withFileSystemBind(DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), "/var/run/docker.sock"); |
can also be moved to the configure method.
Relevant log output
13:24:08.639 INFO org.testcontainers.images.PullPolicy - Image pull policy will be performed by: DefaultPullPolicy()
13:24:08.643 INFO org.testcontainers.utility.ImageNameSubstitutor - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
13:24:08.894 INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
13:24:08.907 WARN org.testcontainers.dockerclient.DockerClientProviderStrategy - DOCKER_HOST tcp://127.0.0.1:57810 is not listening
13:24:08.907 WARN org.testcontainers.dockerclient.DockerClientProviderStrategy - DOCKER_HOST tcp://127.0.0.1:57810 is not listening
13:24:09.459 INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Docker accessed via Unix socket (/Users/eddumelendez/.docker/run/docker.sock)
13:24:09.466 INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
13:24:09.488 INFO org.testcontainers.DockerClientFactory - Connected to docker:
Server Version: 24.0.6
API Version: 1.43
Operating System: Docker Desktop
Total Memory: 9951 MB
13:24:09.492 INFO org.testcontainers.DockerClientFactory - Checking the system...
13:24:09.493 INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
13:24:09.534 INFO tc.localstack/localstack:2.0 - LOCALSTACK_HOST environment variable set to localstack (to match last network alias on container with non-default network)
13:24:09.535 INFO tc.localstack/localstack:2.0 - Creating container for image: localstack/localstack:2.0
13:24:09.652 INFO org.testcontainers.utility.RegistryAuthLocator - Credential helper/store (docker-credential-osxkeychain) does not have credentials for https://index.docker.io/v1/
13:24:09.657 INFO tc.testcontainers/ryuk:0.5.1 - Creating container for image: testcontainers/ryuk:0.5.1
13:24:09.743 INFO tc.testcontainers/ryuk:0.5.1 - Container testcontainers/ryuk:0.5.1 is starting: a711c589efcd55a40c47f58b7a26e34de5a191b47578ae2a9bcc7c9f2c92a9bc
13:24:10.077 INFO tc.testcontainers/ryuk:0.5.1 - Container testcontainers/ryuk:0.5.1 started in PT0.419S
13:24:10.386 INFO tc.localstack/localstack:2.0 - Container localstack/localstack:2.0 is starting: f53fa14c54b7d6c0669d1316c34d6fe0540acf7557f0c5bde234e89a36a4c908
13:24:10.461 ERROR tc.localstack/localstack:2.0 - Could not start container
com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"error while creating mount source path '/host_mnt/Users/eddumelendez/.docker/run/docker.sock': mkdir /host_mnt/Users/eddumelendez/.docker/run/docker.sock: operation not supported"}Additional Information
No response
Activity
Resolve strategy to detect the remote docker socket
Resolve strategy to detect the remote docker socket (#7727)
pdrosos commentedon Oct 28, 2023
Hi @eddumelendez, do you plan to release a new version including this bugfix soon? I am using localstack testcontainer on MacBook M1 with MacOS Sonoma and docker via colima VM with vmType vz and mountType virtiofs. I have the same error (only from the localstack testcontainer, my other postgresql testcontainer works):
The error happens only if I create colima VM with vmType vz and mountType virtiofs, if vmType qemu and mountType sshfs are used instead, then the localstack testcontainer works.
Resolve strategy to detect the remote docker socket (testcontainers#7727