Skip to content

Clarification working with WSL : Working with WSL docker installation with testcontainers complains on could not find docker enviornment #5054

Closed

Description

@gavasv

Below error appears when i run my integration tests through WSL docker.

Error : Caused by: java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$4(DockerClientProviderStrategy.java:156)

Note : Integration tests are able to find docker environment when I have have docker desktop/docker installation on windows machine.

Any hints on how to run these with intellij + WSL would be appreciated.

More info on the way I create container :
{
private static final DockerImageName COUCHBASE_IMAGE = DockerImageName.parse("couchbase/server:7.0.0");

public static final String USERNAME = "admin";
public static final String PASSWORD = "admin1";
public static final String BUCKET_NAME = "designer";

public static class CouchbaseContainerStartable extends CouchbaseContainer {
    public CouchbaseContainerStartable(DockerImageName dockerImageName) {
        super(dockerImageName);
    }

    public CouchbaseContainer startCouchbase() {
        super.start();
        configureBucketScope();
        configureBucketCollection();
        return this;
    }

}

Activity

  1. gavasv commented on Feb 22, 2022

    @gavasv
    Author

    @daschl @kiview
    Any suggestions on this topic ??

  2. kiview commented on Feb 22, 2022

    @kiview
    Member

    Testcontainers works OOTB with Docker Desktop on Windows and the now default WSL2 backend. Please share more details about your setup and logs.

    I also don't understand why you subclass CouchbaseContainer like this. Please verify a working Testcontainers environment by trying out our simple reproducer:
    https://github.com/testcontainers/testcontainers-java-repro

    @daschl This is unrelated to CouchbaseContainer.

  3. gavasv commented on Feb 22, 2022

    @gavasv
    Author

    Hello @kiview,
    To briefly describe what I want to achieve, and the history behind these questions.

    1. we had developed an integration test suite which was working on the docker desktop.
    2. Docker desktop is now replaced with WSL, so I could run integration tests with containers.

    Now, I want to run integration test cases WSL + intellij on windows machines which gives me error about unable to find docker environment. I would like our developers to work with intellij windows wsl and have ability to run integration tests from intellij.

    I hope you got my problem statement, let me know if more info is needed.

    Thanks Vishal

  4. kiview commented on Feb 22, 2022

    @kiview
    Member

    On Windows Testcontainers only supports Docker Desktop officially.

    If you run your tests from within WSL with Docker running in WSL, Testcontainers should work OOTB.

    For making Testcontainers work from the Windows host with a Docker daemon running inside WSL, make sure you configure the Docker daemon to be accessible by the Windows host and configure Testcontainers for a remote Docker daemon connection:
    https://www.testcontainers.org/features/configuration/#customizing-docker-host-detection

    I will convert this issue into a GH Discussion question.

  5. locked and limited conversation to collaborators on Feb 22, 2022
  6. converted this issue into a discussion #5110 on Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions