我使用brew install docker
安装了Docker可执行文件,并且可以在PATH
的{{1}}中看到它:
bash
我为此$ which docker
/usr/local/bin/docker
设置了一个Spring Boot应用程序:
Dockerfile
当我运行Docker GUI应用程序时,Maven会构建该应用程序,我可以运行它并在本地查看它。但是,当Docker GUI应用程序未运行时,即使它在bash可执行文件中,Maven也无法构建该应用程序,因为它无法建立与Docker的连接:
FROM openjdk:8-jre
MAINTAINER ...
COPY dist /dist/
ARG JAR_FILE
COPY target/${JAR_FILE} /target/app.jar
EXPOSE 8080
CMD ["java", "-jar", "/target/app.jar"]
Maven使用的$ mvn clean install
[INFO] Scanning for projects...
...
[WARNING] An attempt failed, will retry 1 more times
org.apache.maven.plugin.MojoExecutionException: Could not build image
...
Caused by: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: Connection refused
...
Caused by: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: Connection refused
...
Caused by: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: Connection refused
...
Caused by: java.io.IOException: Connection refused
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 38.498 s
[INFO] Finished at: 2018-09-12T11:39:34+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.4:build (default) on project econometer: Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: Connection refused -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
与PATH
不同吗?如何将docker可执行文件的路径提供给Maven?
答案 0 :(得分:0)
Docker使用客户端-服务器架构,“鲸鱼”应用程序提供其中一半的“服务器”。在Mac上,您需要运行桌面应用程序(或重量较大的VM,例如Docker Machine或minikube
提供的VM),以使用任何Docker命令或与Docker进行交互。