Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Volume Specification for Docker socket on Colima #5257

Closed
sanimalp opened this issue Apr 11, 2022 · 2 comments
Closed

Invalid Volume Specification for Docker socket on Colima #5257

sanimalp opened this issue Apr 11, 2022 · 2 comments
Labels
resolution/waiting-for-info Waiting for more information of the issue author or another 3rd party. type/question

Comments

@sanimalp
Copy link

Preface: This is not working on an M1 apple laptop, but working on an AMD64 apple laptop

I have been working to get localstack working in some spock tests on an apple m1 laptop using Colima for docker-desktop-like functionality. This is the issue we have encountered:

 com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"invalid volume specification: 'unix:///Users/<username>/.colima/docker.sock:/var/run/docker.sock:rw'"}
        at app//org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:247)
        at app//org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.post(DefaultInvocationBuilder.java:124)
        at app//org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:37)
        at app//org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:13)
        at app//org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
        at app//org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
        at app//org.testcontainers.shaded.com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:609)
        at app//org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:116)
        at app//org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:219)
        at app//org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:101)
        at app//com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:107)
        at app//org.testcontainers.containers.GenericContainer.start(GenericContainer.java:316)
        at org.testcontainers.spock.TestcontainersMethodInterceptor.startContainers_closure3(TestcontainersMethodInterceptor.groovy:83)
        at app//groovy.lang.Closure.call(Closure.java:412)
        at app//groovy.lang.Closure.call(Closure.java:428)

the creation of the container is as follows:

    @Shared
    DockerImageName localstackImage = DockerImageName.parse("localstack/localstack:latest");
    @Shared
    LocalStackContainer localStack = new LocalStackContainer(localstackImage, false)
            .withServices(LocalStackContainer.Service.DYNAMODB)
            .withEnv("DEFAULT_REGION", "us_east-1")

and usage looks like

def ddbClient = new AmazonDynamoDBClientBuilder()
                .withCredentials(localStack.getDefaultCredentialsProvider())
                .withEndpointConfiguration(localStack.getEndpointConfiguration(LocalStackContainer.Service.DYNAMODB))
                .build()

We have had to set the following env in the shell:

export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=unix://${HOME}/.colima/docker.sock

for the colima specific behavior and settings.

It might be possible that something in the environment is not set properly, causing this, but we have tried to find env that might affect this with no luck.

@kiview
Copy link
Member

kiview commented Apr 13, 2022

Hi @sanimalp, can you please try to verify, if this is in any way related to localstack & Spock, or just specific to your Colima setup? Did you substitute your username in the logs? unix:///Users/<username>/.colima/docker.sock:/var/run/docker.sock:rw

And looking at this older issue about Colima, I think you need to apply the following config:

export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"

The best start would be to try out our reproducer in your environment:
https://github.com/testcontainers/testcontainers-java-repro

@kiview kiview added type/question resolution/waiting-for-info Waiting for more information of the issue author or another 3rd party. labels Apr 13, 2022
@kiview kiview changed the title localstack+spock modules "Invalid Volume Specification" Invalid Volume Specification for Docker socket on Colima Apr 13, 2022
@bsideup
Copy link
Member

bsideup commented Apr 13, 2022

I think the issue was in the wrong usage of TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE. It should point to a file and is not an URI (so you don't need unix://).

See https://www.testcontainers.org/features/configuration/#customizing-docker-host-detection

@bsideup bsideup closed this as completed Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution/waiting-for-info Waiting for more information of the issue author or another 3rd party. type/question
Projects
None yet
Development

No branches or pull requests

3 participants