springboot项目构建docker镜像异常: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded
异常信息
在centos上构建springboot项目的docker镜像时出现以下异常:
Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project dockerDemo: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.client.ClientProtocolException: Cannot retry request with a non-repeatable request entity: Connection reset by peer -> [Help 1]
使用的是docker-maven插件,pom.xml配置如下:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
解决方法
把要构建的镜像名称全部改为小写,这里配置为<imageName>${docker.image.prefix}/${project.artifactId}</imageName>,所以要保证项目的artifactId为小写。
方案来源:
issue地址:https://github.com/spotify/docker-maven-plugin/issues/357