kotlinquarkuscolima

Could not find a valid Docker Environment


I just download a new project from https://code.quarkus.io with Kotlin + Gradle + REST and tried to execute ./gradlew quarkusDev and encountered following error:

2023-04-18 17:05:57,007 INFO  [org.tes.doc.DockerMachineClientProviderStrategy] (build-44) docker-machine executable was not found on PATH ***(masked on purpose) ***
2023-04-18 17:05:57,024 ERROR [org.tes.doc.DockerClientProviderStrategy] (build-44) Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
        UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (Could not find unix domain socket). Root cause NoSuchFileException (/var/run/docker.sock)As no valid configuration was found, execution cannot continue.
See https://www.testcontainers.org/on_failure.html for more details.
     2023-04-18 17:05:57,282 INFO  [org.tes.uti.ImageNameSubstitutor] (build-44) Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
<====2023-04-18 17:05:57,288 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
<====2023-04-18 17:05:57,613 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.kafka.client.deployment.DevServicesKafkaProcessor#startKafkaDevService threw an exception: java.lang.RuntimeException: java.lang.IllegalStateException: Previous attempts to find a Docker environment failed. Will not retry. Please see logs and check configuration
        at io.quarkus.kafka.client.deployment.DevServicesKafkaProcessor.startKafkaDevService(DevServicesKafkaProcessor.java:105)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:1623)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.IllegalStateException: Previous attempts to find a Docker environment failed. Will not retry. Please see logs and check configuration
        at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:212)
        at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:150)
        at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:186)
        at org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:104)
        at com.github.dockerjava.api.DockerClientDelegate.listContainersCmd(DockerClientDelegate.java:188)
        at io.quarkus.devservices.common.ContainerLocator.lookup(ContainerLocator.java:32)
        at io.quarkus.devservices.common.ContainerLocator.locateContainer(ContainerLocator.java:45)
        at io.quarkus.kafka.client.deployment.DevServicesKafkaProcessor.startKafka(DevServicesKafkaProcessor.java:222)
        at io.quarkus.kafka.client.deployment.DevServicesKafkaProcessor.startKafkaDevService(DevServicesKafkaProcessor.java:95)
        ... 9 more

My setup:

quarkus --version                                                                                                                                                                                                0|1 ↵  6451  17:15:31
2.16.6.Final


gradle --version                                                                                                                                                                                                    

------------------------------------------------------------
Gradle 8.1
------------------------------------------------------------

Build time:   2023-04-12 12:07:45 UTC
Revision:     40ba32cde9d6daf2b92c39376d2758909dd6b813

Kotlin:       1.8.10
Groovy:       3.0.15
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          20 (Homebrew 20)
OS:           Mac OS X 11.6.2 x86_64
-------------------------------------------------
colima version    
                                                                                                                                                                                                  
colima version 0.5.4
git commit: feef4176f56a7dea487d43689317a9d7fe9de27e

runtime: docker
arch: x86_64
client: v20.10.22
server: v20.10.20

I haven't added any code apart from the skeleton provided by the builder and as stated above I am using colima instead of docker.


Solution

  • In your logs, you can see that Quarkus is trying to find docker socket in /var/run/docker.sock

    But when using Colima, path is different :

    v0.3.4 or older -> Docker socket is located at $HOME/.colima/docker.sock

    v0.4.0 or newer -> Docker socket is located at $HOME/.colima/default/docker.sock

    It can also be retrieved by checking status with colima status

    As you are currently using Colima v0.5.4, I suppose Quarkus should look to path $HOME/.colima/default/docker.sock. But to be extra confident, simply run colima status to get the actual one.

    Properly configure env so Quarkus can find Docker .sock

    You'll have to indicate it by running this command :

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

    OR Disable devServices

    You can disable devServices, thus quarkus won't need docker to start anymore : Simply add this quarkus.devservices.enabled=false in your application.properties