maven+docker构建springboot时,报"POST unix://localhost:80/build?t="的错

具体报错如下:

[INFO] Copying /root/springcloudconfig2/EurekaClient/target/EurekaClient-0.0.1-SNAPSHOT.jar -> /root/springcloudconfig2/EurekaClient/target/docker/EurekaClient-0.0.1-SNAPSHOT.jar
[INFO] Copying /root/springcloudconfig2/EurekaClient/src/main/docker/Dockerfile -> /root/springcloudconfig2/EurekaClient/target/docker/Dockerfile
[INFO] Building image luoch/EurekaClient
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.088s
[INFO] Finished at: Tue Dec 12 16:10:01 CST 2017
[INFO] Final Memory: 41M/98M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.3:build (default-cli) on project EurekaClient: Exception caught: Request error: POST unix://localhost:80/build?t=luoch/EurekaClient: 500: HTTP 500 Internal Server Error -> [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

产生错误的pom.xml:


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

            
                com.spotify
                docker-maven-plugin
                0.4.3
               
                ${docker.image.prefix}/${project.artifactId}
                    /src/main/docker
                   
                       
                            /
                ${project.build.directory}
                            ${project.build.finalName}.jar
                       

                   

               

           

        

    

错误的原因

1.${docker.image.prefix}/${project.artifactId}

imagename中字母必须全部小写,我的${project.artifactId}中含有大写字母

2.  /src/main/docker

 路径改为${project.basedir}/src/main/docker

更改之后的pom.xml


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

            
                com.spotify
                docker-maven-plugin
                0.4.3
               
                luo/ec
                    ${project.basedir}/src/main/docker
                   
                       
                            /
                ${project.build.directory}
                            ${project.build.finalName}.jar
                       

                   

               

           

        

    

最后构建成功

[INFO] Copying /root/springcloudconfig2/EurekaClient/target/EurekaClient-0.0.1-SNAPSHOT.jar -> /root/springcloudconfig2/EurekaClient/target/docker/EurekaClient-0.0.1-SNAPSHOT.jar
[INFO] Copying /root/springcloudconfig2/EurekaClient/src/main/docker/Dockerfile -> /root/springcloudconfig2/EurekaClient/target/docker/Dockerfile
[INFO] Building image luo/ec
Step 1 : FROM frolvlad/alpine-oraclejdk8:slim
 ---> 335b88ca5a30
Step 2 : VOLUME /tmp
 ---> Using cache
 ---> f5f2e9ee3094
Step 3 : ADD ./EurekaClient-0.0.1-SNAPSHOT.jar app.jar
 ---> ac784888e583
Removing intermediate container cf5c272cdd5d
Step 4 : ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
 ---> Running in 7f2a62dd677a
 ---> e48637570e04
Removing intermediate container 7f2a62dd677a
Step 5 : EXPOSE 8761
 ---> Running in 046259d3e60d
 ---> e15cd3106f5f
Removing intermediate container 046259d3e60d
Successfully built e15cd3106f5f
[INFO] Built luo/ec
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.303s
[INFO] Finished at: Tue Dec 12 16:11:33 CST 2017
[INFO] Final Memory: 40M/96M
[INFO] ------------------------------------------------------------------------

注意:

1.在项目的/src/main下创建一个docker目录,在docker目录下创建Dockerfile文件

2 Dockerfile

FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD ./EurekaClient-0.0.1-SNAPSHOT.jar app.jar
#RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
EXPOSE 8761

ADD 指令后面的第一个路径是jar相对于/target/docker/Dockerfile的路径  第二个是容器中的路径




你可能感兴趣的:(docker)