springboot+Jib+Maven+Idea+Docker 实践
Jib - Containerize your Maven project
用Jib配置idea的maven项目中,实现springboot、tomcat 来build镜像
2. Jib+Maven+Springboot 实践代码例子
2.1在maven项目中的pom.xml文件中配置Jib插件
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.0.1</version>
</plugin>
pluginManagement & plugins 如果在idea右边不显示插件jib,注意把pluginManagement注释了,就可以正常显示了

2.2 配置详情
1.这里有一个验证直接使用用户名和密码,来替代credHelper使用。验证成功后可以直接从Docker hub或者网易hub.c.163.com上获取官方镜像(依据个人喜好配置对应的auth)
<!--jib 构建插件-->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<from>
<image>openjdk:alpine</image>
<!--直接指定凭证(替代credHelper)-->
<auth>
<username>${registry_username}</username>
<password>${registry_password}</password>
</auth>
</from>
<to>
<image>${registry_url}/${project.artifactId}</image>
<tags>
<tag>latest</tag>
</tags>
</to>
<container>
<mainClass>com.ecdata.CmpApplication</mainClass>
<!--使用当前时间-->
<useCurrentTimestamp>true</useCurrentTimestamp>
<!--容器在运行时暴露的端口-->
<ports>
<port>8088</port>
</ports>
</container>
<!--如果私有镜像仓库没有启用https,设置allowInsecureRegistries参数为true-->
<allowInsecureRegistries>false</allowInsecureRegistries>
</configuration>
<!--绑定jib:build到 Maven生命周期,例如package-->
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
已绑定jib:build到 Maven生命周期package,所以直接运行package

2.2 运行效果展示:
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cmp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ws/dev/sourceCode/ideaProjects/sw/cmp/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ cmp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 13 source files to /Users/ws/dev/sourceCode/ideaProjects/sw/cmp/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ cmp ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ cmp ---
[INFO] Building jar: /Users/ws/dev/sourceCode/ideaProjects/sw/cmp/target/cmp-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) @ cmp ---
[INFO]
[INFO] --- jib-maven-plugin:1.0.1:dockerBuild (default) @ cmp ---
[WARNING] Setting image creation time to current time; your image may not be reproducible.
[INFO]
[INFO] Containerizing application to Docker daemon as 31.16.14.55/szy/cmp, 31.16.14.55/szy/cmp...
[INFO] Getting base image openjdk:alpine...
[INFO] Building dependencies layer...
[INFO] Building resources layer...
[INFO] Building classes layer...
[INFO] The base image requires auth. Trying again for openjdk:alpine...
[INFO] Retrieving registry credentials for registry.hub.docker.com...
[INFO]
[INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, com.ecdata.CmpApplication]
[INFO] Loading to Docker daemon...
[INFO]
[INFO] Built image to Docker daemon as 31.16.14.55/szy/cmp, 31.16.14.55/szy/cmp
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.268 s
[INFO] Finished at: 2019-02-27T09:55:16+08:00
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
2.3 验证生成好的镜像:
sai:~ ws$ docker images | grep 31.16.14.55/szy/cmp
31.16.14.55/szy/cmp latest 70440c0ad660 6 minutes ago 213MB
sai:~ ws$
2.4 push镜像到镜像仓库:
sai:~ ws$ docker push31.16.14.55/szy/cmp
</div>
原文地址:https://blog.csdn.net/shenhonglei1234/article/details/87967088
springboot+Jib+Maven+Idea+Docker 实践的更多相关文章
- springboot程序构建一个docker镜像(十一)
准备工作 环境: linux环境或mac,不要用windows jdk 8 maven 3.0 docker 对docker一无所知的看docker教程. 创建一个springboot工程 引入web ...
- Spring Boot教程(十一) springboot程序构建一个docker镜像
准备工作 环境: linux环境或mac,不要用windows jdk 8 maven 3.0 docker 对docker一无所知的看docker教程. 创建一个springboot工程 引入web ...
- docker 运行jenkins及vue项目与springboot项目(五.jenkins打包springboot服务且在docker中运行)
docker 运行jenkins及vue项目与springboot项目: 一.安装docker 二.docker运行jenkins为自动打包运行做准备 三.jenkins的使用及自动打包vue项目 四 ...
- SpringBoot系列之自定义starter实践教程
SpringBoot系列之自定义starter实践教程 Springboot是有提供了很多starter的,starter翻译过来可以理解为场景启动器,所谓场景启动器配置了自动配置等等对应业务模块的一 ...
- Springboot整合MongoDB的Docker开发,其它应用也类似
1 前言 Docker是容器开发的事实标准,而Springboot是Java微服务常用框架,二者必然是会走到一起的.本文将讲解如何开发Springboot项目,把它做成Docker镜像,并运行起来. ...
- Docker实践,来自沪江、滴滴、蘑菇街架构师的交流分享
架构师小组交流会:每期选一个时下最热门的技术话题进行实践经验分享. 第一期主题:容器实践.Docker 作为当前最具颠覆性的开源技术之一,其轻量虚拟化.可移植性是CI/CD,DevOps,微服务的重要 ...
- 菜鸟——springboot+mybatis+maven
网上找了很多资料,学习如何搭建springboot,由于刚刚接触springboot,不是很熟练,通过参考网上别人搭建的例子,自己也搭建了一个简单的springboot+mybaits+maven 网 ...
- springboot创建maven多模块项目
SpringBoot创建maven多模块项目 项目结构 该项目名称为springboot-maven-multi,由springboot-maven-multi.user-dao.user-domai ...
- (一 、上)搭建简单的SpringBoot + java + maven + mysql + Mybatis+通用Mapper 《附项目源码》
最近公司一直使用 springBoot 作为后端项目框架, 也负责搭建了几个新项目的后端框架.在使用了一段时间springBoot 后,感觉写代码 比spring 更加简洁了(是非常简洁),整合工具也 ...
随机推荐
- Windows上PostgreSQL安装配置教程
Windows上PostgreSQL安装配置教程 这篇文章主要为大家详细介绍了Windows上PostgreSQL安装配置教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 PostgreSQL的 ...
- Java基础面试操作题:线程同步代码块 两个客户往一个银行存钱,每人存三十次一次存一百。 模拟银行存钱功能,时时银行现金数。
package com.swift; public class Bank_Customer_Test { public static void main(String[] args) { /* * 两 ...
- Ping 命令的执行过程和应用协议
1. ICMP是“Internet Control Message Ptotocol”的缩写.它是TCP/IP协议族的一个子协议,用于在IP主机.路由器之间传递控制消息. 控制消息是指网络通不通.主机 ...
- 二分查找、upper_bound、lower_bound
整理及总结二分查找的判断和边界细节 修改版 package com.leej.binarysearch; import java.util.Arrays; /** * @author jerry * ...
- 使用kickstart + pxe 部署无人值守安装
1.作为中小公司的运维,经常会遇到一些机械式的重复工作,例如:有时公司同时上线几十甚至上百台服务器,而且需要我们在短时间内完成系统安装. 常规的安装系统方法: 光盘安装系统:一个服务器DVD内置光驱百 ...
- destoon 屏蔽会员组,让个人,游客不显示
include/post.fun.php 文件的group_select函数增加 排除参数 except function group_select($name = 'groupid', $titl ...
- drf版本控制 django缓存
drf的版本控制 内置的版本控制类 from rest_framework.versioning import QueryParameterVersioning,AcceptHeaderVersion ...
- Linux异常体系之vector_stub宏解析
ARM-Linux汇编的宏定义语法说明如下: 使用注意: 1.宏定义以.macro开始,以.endm结束 2.可带参数,参数可有默认值 3.直接使用参数的名字\arg vector_stub宏的功能: ...
- LeetCode(205)Isomorphic Strings
题目 Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the ch ...
- NordicSemiconductor.nRF_DeviceFamilyPack 更新历史记录
Version: 8.17.0 (2018-04-27) NordicSemiconductor.nRF_DeviceFamilyPack.8.17.0.packDownload For nRF528 ...