通过maven 打docker 镜像包,出错ADD failed: stat /var/lib/docker/tmp/docker-builderXXXXXX: no such file or dir

直接用maven打包成docker镜像的时候,就报这个错, 

最开始以为是 spring-boot-starter-parent2.0.3.RELEASE 版本问题,改成1.5.6版本就可能 顺利打包,最后排查到是打包文件名不一致,坑啊

其实就是pom.xml文件与dockerFile生成镜像文件名不一致,

pom.xml里会自带后缀名 ,就是版本号,黑色字体要注意,

com.example.euraka
demoServerClient
0.0.1-SNAPSHOT  
jar

dcokerfile 文件里 ADD testeuraka-0.0.1.jar /app/app.jar 是这样

这两个地方统一就OK   所以我把pom.xml里的SNAPSHOT后缀去掉了

ADD testeuraka-0.0.1-SNAPSHOT.jar app.jar  要和pom的testeuraka


BUILD FAILURE

[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.107 s
[INFO] Finished at: 2018-07-05T13:58:55+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project euraka-server: Exception caught: lstat springCloudEuraka-1.0.0.jar: no such file or directory -> [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


第一次打包镜像下载的东西很多, 也是报错

 Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.3.RELEASE:repackage (default) on project euraka-server: 
 Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.3.RELEASE:repackage failed: 
 Plugin org.springframework.boot:spring-boot-maven-plugin:2.0.3.RELEASE or one of its dependencies could not be resolved:
 Could not transfer artifact com.google.guava:guava:jar:11.0.2 from/to alimaven (http://maven.aliyun.com/nexus/content/groups/public/):
 GET request of: com/google/guava/guava/11.0.2/guava-11.0.2.jar from alimaven 

 failed: Premature end of Content-Length delimited message body (expected: 1648200; received: 277655 -> [Help 1]

这是第三次才出现的错误,统统把他们放在一起处理

BUILD FAILURE
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project testeuraka: 

Exception caught: ADD failed: stat /var/lib/docker/tmp/docker-builder974844977/testeuraka-1.0.0.jar: no such file or directory -> [Help 1]


以下是我的正确配置

Dockerfile

FROM java:8
VOLUME /tmp
RUN mkdir /app
ADD testeuraka-0.0.1.jar /app/app.jar
ADD runboot.sh /app/
RUN bash -c 'touch /app/app.jar'
WORKDIR /app
RUN chmod a+x runboot.sh
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ 
    echo 'Asia/Shanghai' >/etc/timezone
EXPOSE 5010

CMD /app/runboot.sh

下面是pom.xml


xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0


com.example.euraka
testeuraka
0.0.1
jar


testeuraka
Demo project for Spring Boot



org.springframework.boot
spring-boot-starter-parent
2.0.3.RELEASE





UTF-8
UTF-8
2.9.2
1.8
http://192.168.11.233:2375 
Finchley.RELEASE





org.springframework.cloud
spring-cloud-starter-netflix-eureka-server




org.springframework.boot
spring-boot-starter-test
test







org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import








org.springframework.boot
spring-boot-maven-plugin


com.spotify
docker-maven-plugin

${docker.url}
${project.name}:${project.version}
${project.basedir}/src/main/docker
false


/
${project.build.directory}
${project.build.finalName}.jar











你可能感兴趣的:(通过maven 打docker 镜像包,出错ADD failed: stat /var/lib/docker/tmp/docker-builderXXXXXX: no such file or dir)