kotlin 找不到有效的Docker环境

hujrc8aj  于 2023-04-21  发布在  Kotlin
关注(0)|答案(2)|浏览(168)

我刚用Kotlin+ Gradle + REST从https://code.quarkus.io下载了一个新项目,并尝试执行./gradlew quarkusDev,遇到了以下错误:

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

我的设置:

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

除了构建器提供的框架之外,我没有添加任何代码,如上所述,我使用colima而不是docker。

qgelzfjb

qgelzfjb1#

在您的日志中,您可以看到Quarkus正在尝试在/var/run/docker.sock中查找docker socket
但使用Colima时,路径不同:
v0.3.4或更早版本-〉Docker socket位于$HOME/.colima/docker.sock
v0.4.0或更新版本-〉Docker socket位于$HOME/.colima/default/docker.sock
也可以通过使用colima status检查状态来检索
由于您目前使用的是Colima v0.5.4,我认为Quarkus应该查找路径$HOME/.colima/default/docker.sock。但为了更加自信,只需运行colima status即可获得实际的路径。

正确配置env,以便Quarkus可以找到Docker .sock

您必须通过运行以下命令来指示它:

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

或关闭devServices

你可以禁用devServices,这样quarkus就不再需要docker来启动了:只需将此quarkus.devservices.enabled=false添加到您的application.properties

8gsdolmq

8gsdolmq2#

此错误告诉您在构建过程中,Docket进程预计将在您的机器上运行。例如,Tescontainers库使用Docker启动应用程序依赖于测试的进程(例如数据库)。要解决此问题,请下载并安装适合您操作系统的Docker版本。您可以在Docker网站上找到如何执行此操作的说明:https://docs.docker.com/engine/install/

相关问题