本篇文章我们将介绍如何在 IDE 工具 idea 中使用 Docker 工具,并为我们的工程构建镜像。
- 实战
2.1 创建父工程 chapter18
父工程 pom.xml 依赖文件:
代码清单:chapter18/pom.xml
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${
dockerfile.maven.version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${
docker.image.prefix}/${
project.artifactId}</repository>
<tag>${
project.version}</tag>
<buildArgs>
<JAR_FILE>${
project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
版本笔者这里选择的是 v1.4.12 ,也是目前官方仓库上最新的版本,此版本于 2019年7月30日 发布。
标签中是一些有关于 Docker 镜像相关的配置,包括当前的 和 。但是经笔者测试,如果使用 idea 生成远端镜像(本地无Docker服务),这两个部分还是会为 null 的,生成完后需要使用命令 docker tag [imageId] [repository]:[tag] 来重新命名镜像。如果本地有 Docker 服务,则无此问题。
2.2 创建子工程 eureka-server
2.2.1 子工程依赖 pom.xml 如下:
代码清单:chapter18/eureka_server/pom.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>