dockerfile-maven-plugin極簡(jiǎn)教程(推薦)
一、簡(jiǎn)介
maven是一個(gè)項(xiàng)目依賴管理和構(gòu)建的工具,dockerfile-maven-plugin是一個(gè)maven的插件,主要作用是在項(xiàng)目構(gòu)建的時(shí)候生成基于項(xiàng)目的docker鏡像文件。
簡(jiǎn)而言之,此插件將maven和docker進(jìn)行集成。
正常情況下,我們?cè)陂_發(fā)了一個(gè)應(yīng)用程序后,會(huì)使用maven進(jìn)行打包,生成對(duì)應(yīng)的jar文件。而后,會(huì)使用docker將jar文件build成一個(gè)鏡像(docker image)。之后,就可以在docker daemon中創(chuàng)建基于鏡像的容器,并可提供服務(wù)了。
dockerfile-maven-plugin的目標(biāo)就是將maven的打包過程和docker的build過程結(jié)合在一起,當(dāng)成功打包,既生成了對(duì)應(yīng)的jar,也已生成了對(duì)應(yīng)的docker鏡像。當(dāng)然,這只是最基礎(chǔ)的功能,更詳細(xì)的功能參見:https://github.com/spotify/dockerfile-maven
二、概述
我們知道m(xù)aven是apache公司開發(fā)的一個(gè)產(chǎn)品,但是dockerfile-maven-plugin并不是apache官方開發(fā)的插件,是由一個(gè)叫做Spotify的組織開發(fā)的。
github主頁(yè):https://spotify.github.io/
github開源地址:https://github.com/spotify/dockerfile-maven
本文僅討論如何基于一個(gè)Spring Boot的項(xiàng)目生成對(duì)應(yīng)的docker鏡像。
基本的原理如下:
- 首先,dockerfile-maven-plugin插件已經(jīng)存儲(chǔ)在maven的倉(cāng)庫(kù)中
- 然后,當(dāng)在本地開發(fā)的時(shí)候,需要在項(xiàng)目的pom文件中引入此插件,在pom-build-plugins下面增加plugin配置節(jié)點(diǎn)
- 再然后,在executions節(jié)點(diǎn)中配置此插件如何工作;并且在configuration節(jié)點(diǎn)中加入需要的配置信息
- 最后,當(dāng)我們執(zhí)行mvn package的時(shí)候就可以得到docker image 了
環(huán)境:
- Ideal版本:2020.01
- java版本:8
- maven版本:3.6.1
- docker版本:19.03.12
ideal和docker deamon運(yùn)行在同一臺(tái)機(jī)器上面
三、將spring-boot-app打包成docker鏡像
創(chuàng)建示例應(yīng)用
使用ideal自帶的Spring Initializr生成一個(gè)Spring Web 的示例項(xiàng)目
app對(duì)外提供一個(gè)hello的接口,訪問該接口可以得到Hello,World的響應(yīng)結(jié)果。應(yīng)用主啟動(dòng)類代碼如下:
package com.naylor.dockerfilemavenplugin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/")
@SpringBootApplication
public class DockerfileMavenPluginApplication {
public static void main(String[] args) {
SpringApplication.run(DockerfileMavenPluginApplication.class, args);
}
@GetMapping("/hello")
public String hello(){
return "Hello,World";
}
}
編譯并運(yùn)行項(xiàng)目,在瀏覽器中訪問「http://127.0.0.1:8080/hello」 可以得到預(yù)期的響應(yīng)結(jié)果
修改pom文件
在pom中增加對(duì)dockerfile-maven-plugin插件的引用,核心代碼如下:
<!-- dockerfile-maven-plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>com.naylor/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
其中:
- g,a,v 為對(duì)插件的引用
- executions中的build標(biāo)識(shí),在maven的packege環(huán)節(jié)執(zhí)行此插件
- configuration中的repository是生成的鏡像的repository信息
- tag為鏡像的tag信息
- buildArgs是在docker構(gòu)建鏡像過程中的參數(shù),此處定義的JAR_FILE參數(shù)在執(zhí)行docker build 的時(shí)候會(huì)消費(fèi)
完整的pom文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.naylor</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>dockerfile-maven-plugin</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- dockerfile-maven-plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>com.naylor/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
增加Dockerfile文件
在項(xiàng)目根目錄(和pom文件在同一級(jí))新建一個(gè)Dokerfile文件,文件內(nèi)容如下:
FROM java:8
EXPOSE 8080
ARG JAR_FILE
ADD target/${JAR_FILE} /app.jar
ENTRYPOINT ["java", "-jar","/app.jar"]
使用Maven打包應(yīng)用
首先清理一下maven工程,在ideal的Maven面版中點(diǎn)擊Lifecycle-clean或者使用命令行執(zhí)行mvn clean。
然后,使用maven構(gòu)建app,在ideal的Maven面版中點(diǎn)擊Liftcycle-package或者使用命令行執(zhí)行 mvn package
再然后在命令行工具中執(zhí)行docker image ls ,如果不出意外,可以看到一個(gè)repository為com.naylor/dockerfile-maven-plugin的docker鏡像。

運(yùn)行應(yīng)用鏡像
在命令行工具中執(zhí)行如下命令運(yùn)行容器:
docker run -d -p 8081:8080 ImageId
- ImageId為上一步生成的鏡像的id,每次生成的鏡像id都不一樣
- 此命令作用為基于ImageId構(gòu)建一個(gè)容器,將宿主機(jī)的8081端口映射到容器的8080端口
在宿主機(jī)瀏覽器中訪問「http://127.0.0.1:8081/hello」可以得到Hello,World的響應(yīng)。
四、分析mvn package 命令的控制臺(tái)輸出
通過mvn package的控制臺(tái)輸出,我們可以清晰的觀察到整個(gè)流程的執(zhí)行步驟,完整的輸出如下:
/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/bin/java -Dmaven.multiModuleProjectDirectory=/Users/chenhd/code/DebrisApp_Springboot/debris-app "-Dmaven.home=/Applications/IntelliJ IDEA 2.app/Contents/plugins/maven/lib/maven3" "-Dclassworlds.conf=/Applications/IntelliJ IDEA 2.app/Contents/plugins/maven/lib/maven3/bin/m2.conf" "-Dmaven.ext.class.path=/Applications/IntelliJ IDEA 2.app/Contents/plugins/maven/lib/maven-event-listener.jar" "-javaagent:/Applications/IntelliJ IDEA 2.app/Contents/lib/idea_rt.jar=58649:/Applications/IntelliJ IDEA 2.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA 2.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.6.0.jar" org.codehaus.classworlds.Launcher -Didea.version2020.1 package
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.naylor:dockerfile-maven-plugin >-----------------
[INFO] Building dockerfile-maven-plugin 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ dockerfile-maven-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ dockerfile-maven-plugin ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ dockerfile-maven-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/chenhd/code/DebrisApp_Springboot/debris-app/dockerfile-maven-plugin/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ dockerfile-maven-plugin ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ dockerfile-maven-plugin ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests
13:49:50.713 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
13:49:50.735 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
13:49:50.762 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
13:49:50.781 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests], using SpringBootContextLoader
13:49:50.785 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests]: class path resource [com/naylor/dockerfilemavenplugin/DockerfileMavenPluginApplicationTests-context.xml] does not exist
13:49:50.785 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests]: class path resource [com/naylor/dockerfilemavenplugin/DockerfileMavenPluginApplicationTestsContext.groovy] does not exist
13:49:50.785 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
13:49:50.786 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests]: DockerfileMavenPluginApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
13:49:50.826 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests]
13:49:50.926 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/chenhd/code/DebrisApp_Springboot/debris-app/dockerfile-maven-plugin/target/classes/com/naylor/dockerfilemavenplugin/DockerfileMavenPluginApplication.class]
13:49:50.932 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplication for test class com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests
13:49:51.069 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests]: using defaults.
13:49:51.070 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
13:49:51.096 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
13:49:51.098 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
13:49:51.098 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@5acf93bb, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@7e7be63f, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@6cd28fa7, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@614ca7df, org.springframework.test.context.support.DirtiesContextTestExecutionListener@4738a206, org.springframework.test.context.event.EventPublishingTestExecutionListener@66d3eec0, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@1e04fa0a, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@1af2d44a, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@18d87d80, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@618425b5, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@58695725, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@543588e6]
13:49:51.114 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@209da20d testClass = DockerfileMavenPluginApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@e15b7e8 testClass = DockerfileMavenPluginApplicationTests, locations = '{}', classes = '{class com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@27ae2fd0, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@4278a03f, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@2bbf180e, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@96def03, org.springframework.boot.test.context.SpringBootTestArgs@1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
13:49:51.152 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-10-12 13:49:51.449 INFO 16693 --- [ main] .d.DockerfileMavenPluginApplicationTests : Starting DockerfileMavenPluginApplicationTests on neiyo with PID 16693 (started by chenhd in /Users/chenhd/code/DebrisApp_Springboot/debris-app/dockerfile-maven-plugin)
2020-10-12 13:49:51.451 INFO 16693 --- [ main] .d.DockerfileMavenPluginApplicationTests : No active profile set, falling back to default profiles: default
2020-10-12 13:49:52.458 INFO 16693 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-10-12 13:49:52.732 INFO 16693 --- [ main] .d.DockerfileMavenPluginApplicationTests : Started DockerfileMavenPluginApplicationTests in 1.559 seconds (JVM running for 2.86)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.313 s - in com.naylor.dockerfilemavenplugin.DockerfileMavenPluginApplicationTests
2020-10-12 13:49:53.042 INFO 16693 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ dockerfile-maven-plugin ---
[INFO] Building jar: /Users/chenhd/code/DebrisApp_Springboot/debris-app/dockerfile-maven-plugin/target/dockerfile-maven-plugin-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.4.RELEASE:repackage (repackage) @ dockerfile-maven-plugin ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- dockerfile-maven-plugin:1.3.6:build (default) @ dockerfile-maven-plugin ---
[INFO] Building Docker context /Users/chenhd/code/DebrisApp_Springboot/debris-app/dockerfile-maven-plugin
[INFO]
[INFO] Image will be built as com.naylor/dockerfile-maven-plugin:0.0.1-SNAPSHOT
[INFO]
[INFO] Step 1/5 : FROM java:8
[INFO]
[INFO] Pulling from library/java
[INFO] Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d
[INFO] Status: Image is up to date for java:8
[INFO] ---> d23bdf5b1b1b
[INFO] Step 2/5 : EXPOSE 8080
[INFO]
[INFO] ---> Using cache
[INFO] ---> 75767466e0be
[INFO] Step 3/5 : ARG JAR_FILE
[INFO]
[INFO] ---> Using cache
[INFO] ---> 2ecdd1234dc2
[INFO] Step 4/5 : ADD target/${JAR_FILE} /app.jar
[INFO]
[INFO] ---> 6169104a5073
[INFO] Step 5/5 : ENTRYPOINT ["java", "-jar","/app.jar"]
[INFO]
[INFO] ---> Running in 23596d4612b6
[INFO] Removing intermediate container 23596d4612b6
[INFO] ---> 993715a0e72a
[INFO] Successfully built 993715a0e72a
[INFO] Successfully tagged com.naylor/dockerfile-maven-plugin:0.0.1-SNAPSHOT
[INFO]
[INFO] Detected build of image with id 993715a0e72a
[INFO] Building jar: /Users/chenhd/code/DebrisApp_Springboot/debris-app/dockerfile-maven-plugin/target/dockerfile-maven-plugin-0.0.1-SNAPSHOT-docker-info.jar
[INFO] Successfully built com.naylor/dockerfile-maven-plugin:0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.597 s
[INFO] Finished at: 2020-10-12T13:50:03+08:00
[INFO] ------------------------------------------------------------------------
重點(diǎn)分析一下此行后面的日志:
--- dockerfile-maven-plugin:1.3.6:build (default) @ dockerfile-maven-plugin ---
Building Docker context /Users/chenhd/code/DebrisApp_Springboot/debris-app/dockerfile-maven-plugin
執(zhí)行dockerfile-maven-plugin項(xiàng)目的docker上下文的構(gòu)建
Image will be built as com.naylor/dockerfile-maven-plugin:0.0.1-SNAPSHOT
構(gòu)建完成之后鏡像的名稱為:com.naylor/dockerfile-maven-plugin:0.0.1-SNAPSHOT
Step 1/5 : FROM java:8
dockerfile中一共定義了5步來執(zhí)行構(gòu)建,第一步是拉取java8的鏡像,如果本地沒有會(huì)從遠(yuǎn)程倉(cāng)庫(kù)中搜索并下載下來
Successfully tagged com.naylor/dockerfile-maven-plugin:0.0.1-SNAPSHOT
成功打包了鏡像
引用
1:官網(wǎng):https://github.com/spotify/dockerfile-maven
2:dockerfile參考:https://docs.docker.com/engine/reference/builder/
到此這篇關(guān)于dockerfile-maven-plugin極簡(jiǎn)教程的文章就介紹到這了,更多相關(guān)dockerfile-maven-plugin內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Java服務(wù)調(diào)用RestTemplate與HttpClient的使用詳解
無論是微服務(wù)還是SOA,都面臨著服務(wù)間的遠(yuǎn)程調(diào)用,這篇文章主要介紹了服務(wù)調(diào)用RestTemplate與HttpClient的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06
idea中無法自動(dòng)裝配未找到 ‘XXXXXXX‘ 類型的 Bean
本文主要介紹了idea中無法自動(dòng)裝配未找到 ‘XXXXXXX‘ 類型的 Bean的原因及三種解決方法,具有一定的參考價(jià)值,感興趣的可以了解一下2024-03-03
Java如何利用Socket進(jìn)行數(shù)據(jù)讀寫
這篇文章主要介紹了Java如何利用Socket進(jìn)行數(shù)據(jù)讀寫,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-10-10
SpringBoot實(shí)現(xiàn)PDF添加水印的示例
本文主要介紹了SpringBoot實(shí)現(xiàn)PDF添加水印的示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05
Java遞歸讀取文件例子_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
本文通過一段示例代碼給大家介紹了java遞歸讀取文件的方法,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2017-05-05
Java之SSM中bean相關(guān)知識(shí)匯總案例講解
這篇文章主要介紹了Java之SSM中bean相關(guān)知識(shí)匯總案例講解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07

