Docker maven插件方式构建微服务镜像
来源:互联网 发布:moment.js实现国际化 编辑:程序博客网 时间:2024/05/21 03:16
Docker maven插件方式构建微服务镜像有两种方式:a.maven集成构建docker镜像 b.外部Dockerfile构建docker镜像。本文介绍的docker插件只适用于微服务jar执行的方式,对于war的构建问题,后面再加以验证补充。插件的Github地址:https://github.com/spotify/docker-maven-plugin
方式一:直接在Maven构建服务镜像
<build> <plugins> ... <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>VERSION GOES HERE</version> <configuration> <imageName>example</imageName> <baseImage>java</baseImage> <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint> <!-- copy the service's jar file from target into the root directory of the image --> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> ... </plugins></build>注:VERSION GOES HERE改为最新的版本即可。
方式二:外部Dockerfile构建服务镜像
<build> <plugins> ... <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>VERSION GOES HERE</version> <configuration> <imageName>example</imageName> <dockerDirectory>docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> ... </plugins></build>
Docker 微服务插件构建实例
请参考: 使用Maven插件构建Docker镜像
在用惯了Tomcat的人看来,是否也可以通过此插件实现呢,这是一个疑问,插件的开发者并没有提及,实际开发和部署过程中也有此要求。请参考问题#238:
Can some one provide a working example for building images in dockerhub using this plugin to deploy war on tomact
此外也可以顺便看看阿里云栖社区的文章:用 Docker 构建、运行、发布一个 Spring Boot 应用
更多官方详情请查阅Github:https://github.com/spotify/docker-maven-plugin
阅读全文
0 0
- Docker maven插件方式构建微服务镜像
- 1.7 Docker与微服务-使用Maven插件构建Docker镜像
- docker构建微服务
- 使用Maven插件构建Docker镜像
- 使用Maven 插件构建docker 镜像和推送仓库
- 通过构建微服务来学习Docker
- Spring Cloud和Docker构建微服务
- Spring Cloud和Docker构建微服务
- Spring Cloud和Docker构建微服务
- docker 构建springboot maven 项目
- maven插件-构建ear
- Spring Cloud和Docker 来构建微服务
- 用Spring Cloud和Docker构建微服务
- 使用Spring Cloud和Docker构建微服务
- Spring boot 与 Docker-compose构建微服务应用
- Spring boot 与 Docker-compose构建微服务应用(2)
- SpringBoot,SpringCloud,Docker构建微服务学习笔记
- 构建微服务实验环境(二):Docker Swarm 集群
- JS数据类型lianxi
- 拉格朗日乘子法和KKT条件
- CSS基础之框架图
- 【读书笔记】锋利的 jQuery
- 给AFN加点Cookie
- Docker maven插件方式构建微服务镜像
- Java学习笔记-数组的静态初始化和动态初始化
- Beyond Compare的文档比较工具的设置
- BigDecimal 分转元
- maven资源文件的相关配置才会在编译后的target里面有
- cf 485d Maximum Value 【二分】
- UNIX环境编程学习笔记(27)——多线程编程(二):控制线程属性
- WEB篇一 初识html
- CodeForces