springboot工程maven打docker镜像并push到hub

      • 修改pom文件
      • 对应docker build
      • 对应docker push

修改pom文件

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
            <plugin>
                <groupId>com.spotifygroupId>
                <artifactId>docker-maven-pluginartifactId>
                <version>1.1.1version>
                <configuration>
                    <imageName>dolphintwo/eureka-serverimageName>
                    <imageTags>
                        <imageTag>${project.version}imageTag>
                        <imageTag>latestimageTag>
                    imageTags>
                    <baseImage>java:8-alpinebaseImage>
                    <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]entryPoint>
                    
                    <resources>
                        <resource>
                            <targetPath>/targetPath>
                            <directory>${project.build.directory}directory>
                            <include>${project.build.finalName}.jarinclude>
                        resource>
                    resources>
                configuration>
            plugin>
        plugins>
    build>

对应docker build

[INFO] Scanning for projects...
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building eureka-server 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- docker-maven-plugin:1.1.1:build (default-cli) @ eureka-server ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] Copying /Users/dd/Documents/work/eureka-server/target/eureka-server-0.0.1.jar -> /Users/dd/Documents/work/eureka-server/target/docker/eureka-server-0.0.1.jar
[INFO] Building image dolphintwo/eureka-server
Step 1/3 : FROM java:8-alpine

---> 3fd9dd82815c
Step 2/3 : ADD /eureka-server-0.0.1.jar //

---> 0136b5d8efdf
Step 3/3 : ENTRYPOINT ["java", "-jar", "/eureka-server-0.0.1.jar"]

---> Running in 59f0eaad991c
Removing intermediate container 59f0eaad991c
---> 15f1a038557f
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built 15f1a038557f
Successfully tagged dolphintwo/eureka-server:latest
[INFO] Built dolphintwo/eureka-server
[INFO] Tagging dolphintwo/eureka-server with 0.0.1
[INFO] Tagging dolphintwo/eureka-server with latest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.294 s
[INFO] Finished at: 2018-08-08T12:13:01+08:00
[INFO] Final Memory: 23M/446M
[INFO] ------------------------------------------------------------------------

对应docker push

INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building eureka-server 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- docker-maven-plugin:1.1.1:push (default-cli) @ eureka-server ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] Pushing dolphintwo/eureka-server
The push refers to repository [docker.io/dolphintwo/eureka-server]
20bd0b791699: Preparing 
a1e7033f082e: Preparing 
78075328e0da: Preparing 
9f8566ee5135: Preparing 
9f8566ee5135: Layer already exists 
a1e7033f082e: Layer already exists 
78075328e0da: Layer already exists 
0.0.1: digest: sha256:c10fdde8b2c54cdcd74f1e3e20f8006446cf358b1e11cf83b2bb89f85d8b7e66 size: 1159
null: null 
20bd0b791699: Preparing 
a1e7033f082e: Preparing 
78075328e0da: Preparing 
9f8566ee5135: Preparing 
a1e7033f082e: Layer already exists 
78075328e0da: Layer already exists 
20bd0b791699: Layer already exists 
9f8566ee5135: Layer already exists 
latest: digest: sha256:c10fdde8b2c54cdcd74f1e3e20f8006446cf358b1e11cf83b2bb89f85d8b7e66 size: 1159
null: null 
[INFO] Pushing dolphintwo/eureka-server:0.0.1
The push refers to repository [docker.io/dolphintwo/eureka-server]
20bd0b791699: Preparing 
a1e7033f082e: Preparing 
78075328e0da: Preparing 
9f8566ee5135: Preparing 
9f8566ee5135: Layer already exists 
20bd0b791699: Layer already exists 
78075328e0da: Layer already exists 
a1e7033f082e: Layer already exists 
0.0.1: digest: sha256:c10fdde8b2c54cdcd74f1e3e20f8006446cf358b1e11cf83b2bb89f85d8b7e66 size: 1159
null: null 
[INFO] Pushing dolphintwo/eureka-server:latest
The push refers to repository [docker.io/dolphintwo/eureka-server]
20bd0b791699: Preparing 
a1e7033f082e: Preparing 
78075328e0da: Preparing 
9f8566ee5135: Preparing 
a1e7033f082e: Layer already exists 
20bd0b791699: Layer already exists 
78075328e0da: Layer already exists 
9f8566ee5135: Layer already exists 
latest: digest: sha256:c10fdde8b2c54cdcd74f1e3e20f8006446cf358b1e11cf83b2bb89f85d8b7e66 size: 1159
null: null 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 59.501 s
[INFO] Finished at: 2018-08-08T12:18:30+08:00
[INFO] Final Memory: 29M/327M
[INFO] ------------------------------------------------------------------------

你可能感兴趣的:(Java,Spring,boot,docker,maven)