Skip to content

Could not find a valid Docker environment. Please see logs and check configuration #4008

Closed

Description

@diogomonte

I have seen similar issues here but I have not found a solution yet to my problem.

I would like to open a new thread here and see if if there is a clear solution for this.
I am using testcontainers 1.15.3:

java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration

	at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$7(DockerClientProviderStrategy.java:215)
	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
	at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:207)
	at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:136)
	at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:178)
	at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)
	at org.testcontainers.LazyDockerClient.authConfig(LazyDockerClient.java:12)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:310)
	at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:1029)
	at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Java 11 installed with homebrew:
DK Runtime Environment (build 11.0.10+9) OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode)

Activity

  1. bsideup commented on Apr 21, 2021

    @bsideup
    Member

    Hi @diogomonte,

    Please share full logs.

  2. diogomonte commented on Apr 21, 2021

    @diogomonte
    Author

    Hi @bsideup ,

    I actually just fixed the issue adding these 2 dependencies together with the latest testcontainers:

            <dependency>
                <groupId>com.github.docker-java</groupId>
                <artifactId>docker-java-api</artifactId>
                <version>3.2.8</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.github.docker-java</groupId>
                <artifactId>docker-java-transport-zerodep</artifactId>
                <version>3.2.8</version>
                <scope>test</scope>
            </dependency>
    
  3. cvetan commented on Apr 21, 2021

    @cvetan

    @diogomonte do you happen to use ARM JDK or Mac with apple silicon chip? The same happens to me with ARM JDK and I wanted to open the same issue.

    Completely the same configuration works with JDK for amd64 platform. When I swith to ARM JDK because performance is much much better, tests crash.

  4. diogomonte commented on Apr 21, 2021

    @diogomonte
    Author

    Hi @cvetan

    Yes. I have the Mac with apple silicon chip.

    Try to add these 2 dependencies:

            <dependency>
                <groupId>com.github.docker-java</groupId>
                <artifactId>docker-java-api</artifactId>
                <version>3.2.8</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.github.docker-java</groupId>
                <artifactId>docker-java-transport-zerodep</artifactId>
                <version>3.2.8</version>
                <scope>test</scope>
            </dependency>
    
  5. bsideup commented on Apr 21, 2021

    @bsideup
    Member

    @diogomonte FYI 1.15.3 already depends on them:
    https://mvnrepository.com/artifact/org.testcontainers/testcontainers/1.15.3

    so maybe there was something that was overriding the dependencies. Anyways, I am glad that you got it solved 👍

  6. cvetan commented on Apr 21, 2021

    @cvetan

    @bsideup Could something be done to support ARM JDK? Because I expect it will be more and more required since new macs will probably more widely used.

  7. bsideup commented on Apr 21, 2021

    @bsideup
    Member

    @cvetan Testcontainers works great with ARM JDKs (I am using M1 myself, btw). Just make sure that you have a version of JNA on classpath that supports M1 (some projects hard force JNA to old versions, for example. 5.7.0 and newer work great with M1).

    Testcontainers 1.15.3 depends on JNA 5.8.0 transitively via docker-java 3.2.8. So, as long as your project isn't doing something shady (e.g. forcing some old versions of transitive dependencies), you will be fine :)

  8. cvetan commented on Apr 21, 2021

    @cvetan

    @bsideup Thanks I will check that out.

  9. martinvw commented on Apr 22, 2021

    @martinvw

    Thanks @bsideup for the new release and the heads up, however I still face some errors here.

    It seems that while there is a dependency to docker-java-transport-zerodep 3.2.8 which depends on jna 5.8.0 there is also a dependency on org.rnorth.visible-assertions » visible-assertions » 2.1.2 which depends on jna 5.2.0

    At least on my machine it still shows jna 5.2.0 if I don't force 5.8.0:

    See the following fragment of mvn dependency:tree

    [INFO] +- org.testcontainers:junit-jupiter:jar:1.15.3:test
    [INFO] |  \- org.testcontainers:testcontainers:jar:1.15.3:test
    [INFO] |     +- org.apache.commons:commons-compress:jar:1.20:test
    [INFO] |     +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:test
    [INFO] |     +- org.rnorth.visible-assertions:visible-assertions:jar:2.1.2:test
    [INFO] |     |  \- net.java.dev.jna:jna:jar:5.2.0:test
    [INFO] |     +- com.github.docker-java:docker-java-api:jar:3.2.8:test
    [INFO] |     \- com.github.docker-java:docker-java-transport-zerodep:jar:3.2.8:test
    [INFO] |        \- com.github.docker-java:docker-java-transport:jar:3.2.8:test
    

    PS no further occurrences of jna appear in the output

  10. tioback commented on Aug 5, 2022

    @tioback

    For future reference:
    While using 1.17.3 I keep getting the "cannot find executable" error mentioned at this issue's description.
    So I downgraded to 1.15.3 and it started working 🤷‍♂️

    I'm running it on a M1 chip, with Docker Desktop 4.10.1 (82475), Java 11, JUnit 4 and docker image confluentinc/cp-kafka:7.0.5-1-ubi8.arm64.

  11. eddumelendez commented on Aug 5, 2022

    @eddumelendez
    Member

    @tioback can you share a sample project that reproduce the issue, please? I have executed the tests in the project with the arm image for kafka and zookeper and everything went well. I think the issue can be related to the project dependencies

  12. JohnnyMarnell commented on Sep 14, 2022

    @JohnnyMarnell

    @bsideup @eddumelendez I've run into this again (last time was an old elasticsearch jar), this time the only JNA dep I see from mvn dependency:tree is from myProject => testcontainers:jar:1.17.3:compile => docker-java-transport-zerodep:jar:3.2.13:compile => jna:jar:4.5.2:compile. Confused why/how it's getting a low version...

    [INFO] +- org.testcontainers:testcontainers:jar:1.17.3:compile
    [INFO] |  +- junit:junit:jar:4.12:compile
    [INFO] |  +- org.slf4j:slf4j-api:jar:1.7.30:compile
    [INFO] |  +- org.apache.commons:commons-compress:jar:1.16.1:compile
    [INFO] |  +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:compile
    [INFO] |  |  \- org.jetbrains:annotations:jar:17.0.0:compile
    [INFO] |  +- com.github.docker-java:docker-java-api:jar:3.2.13:compile
    [INFO] |  \- com.github.docker-java:docker-java-transport-zerodep:jar:3.2.13:compile
    [INFO] |     +- com.github.docker-java:docker-java-transport:jar:3.2.13:compile
    [INFO] |     \- net.java.dev.jna:jna:jar:4.5.2:compile
    
  13. carolcoral commented on Oct 22, 2024

    @carolcoral

    How to fix it? It still happed.And i had add these dependencies:

            <dependency>
                <groupId>com.github.docker-java</groupId>
                <artifactId>docker-java-api</artifactId>
                <version>3.2.8</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.github.docker-java</groupId>
                <artifactId>docker-java-transport-zerodep</artifactId>
                <version>3.2.8</version>
                <scope>test</scope>
            </dependency>
    

    Version

    • Docker: Docker version 27.2.0, build 3ab4256
    • Mac: macOS Sequoia 15.0.1
    • Idea: IntelliJ IDEA 2023.2.7 (Community Edition)

    Image

  14. josesaid commented on Dec 31, 2024

    @josesaid

    By using this solution fixed my issue, thanks
    #4008 (comment)

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions