docker:dockerfile-maven-plugin 构建

  • docker:dockerfile-maven-plugin 配置
<plugin>
    <groupId>com.spotifygroupId>
    <artifactId>dockerfile-maven-pluginartifactId>
    <version>1.4.13version>
    <executions>
        <execution>
            <id>defaultid>
            <goals>
                <goal>buildgoal>
            goals>
        execution>
    executions>
    <configuration>
        <repository>jc0803kevin/${project.artifactId}repository>
        <tag>${project.version}tag>
        <buildArgs>
            
            <JAR_FILE>${project.build.finalName}.jarJAR_FILE>
        buildArgs>
    configuration>
plugin>
  • Dockerfile 文件配置

FROM openjdk:8-jdk-alpine

CMD ["java", "-version"]

EXPOSE 48080

WORKDIR /apps

ARG JAR_FILE

ADD target/${JAR_FILE} app.jar

ENTRYPOINT ["java","-jar","app.jar"]

构建过程 mvn clean package

[INFO] Image will be built as jc0803kevin/springboot-docker:0.0.1-SNAPSHOT
[INFO] 
[INFO] Step 1/7 : FROM openjdk:8-jdk-alpine
[INFO] 
[INFO] Pulling from library/openjdk
[INFO] Digest: sha256:94792824df2df33402f201713f932b58cb9de94a0cd524164a0f2283343547b3
[INFO] Status: Image is up to date for openjdk:8-jdk-alpine
[INFO]  ---> a3562aa0b991
[INFO] Step 2/7 : CMD ["java", "-version"]
[INFO] 
[INFO]  ---> Using cache
[INFO]  ---> 9ad2d0660f8d
[INFO] Step 3/7 : EXPOSE 48080
[INFO] 
[INFO]  ---> Using cache
[INFO]  ---> 6379c6d27deb
[INFO] Step 4/7 : WORKDIR /apps
[INFO] 
[INFO]  ---> Using cache
[INFO]  ---> 4c2883bae779
[INFO] Step 5/7 : ARG JAR_FILE
[INFO] 
[INFO]  ---> Using cache
[INFO]  ---> 8e77c40d1515
[INFO] Step 6/7 : ADD target/${JAR_FILE} app.jar
[INFO] 
[INFO]  ---> 100dc5212c05
[INFO] Step 7/7 : ENTRYPOINT ["java","-jar","app.jar"]
[INFO] 
[INFO]  ---> Running in 4c9d87c835c3
[INFO] Removing intermediate container 4c9d87c835c3
[INFO]  ---> f9ab39fa4a4c
[INFO] Successfully built f9ab39fa4a4c
[INFO] Successfully tagged jc0803kevin/springboot-docker:0.0.1-SNAPSHOT
[INFO] 
[INFO] Detected build of image with id f9ab39fa4a4c

你可能感兴趣的:(docker,maven,容器)