springboot项目打包docker镜像maven插件
<!-- profile docker config -->
<profiles>
<profile>
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.14</version>
<executions>
<!-- when executing mvn package, it will execute mvn docker:build at the same time -->
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<!-- when executing mvn package, it will execute mvn docker:build -DpushImage at the same time -->
<execution>
<id>push-image</id>
<phase>package</phase>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<imageName>${env.DOCKER_REGISTRY_NAME}/${docker.image.prefix}/${project.artifactId}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<forceTags>true</forceTags>
<dockerDirectory>${project.artifactId}/src/main/docker</dockerDirectory>
<serverId>docker-registry</serverId>
<registryUrl>${env.DOCKER_REGISTRY}</registryUrl>
<dockerCertPath>${env.DOCKER_CERT_PATH}</dockerCertPath>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
<activation>
<property>
<name>env</name>
<value>docker</value>
</property>
</activation>
</profile>
</profiles>
其中
env.DOCKER_REGISTRY_NAME = hub.xx.com:10443
env.DOCKER_REGISTRY= https://hub.xx.com:10443
env.DOCKER_CERT_PATH = E:\Doc\cert\hub.xx.com
env.DOCKER_HOST = tcp://172.168.1.1:2375
注意:
最终的镜像一定要是~/~/~:~
格式,如
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
mvn的setting配置
开放docker的2375端口方法
vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
#重新加载docker配置
systemctl daemon-reload // 1,加载docker守护线程
systemctl restart docker // 2,重启docker
如果需要有docker服务器推送到私有中央仓库且为https协议,需要在/etc/docker/certs.d目录下配置证书,证书放置文件夹为私有仓库的域名如hub.123.com:10443
springboot项目打包docker镜像maven插件的更多相关文章
- Azure Devops实践(5)- 构建springboot项目打包docker镜像及容器化部署
使用Azure Devops构建java springboot项目,创建镜像并容器化部署 1.创建一个springboot项目,我用现有的项目 目录结构如下,使用provider项目 在根目录下添加D ...
- Java SpringBoot 项目构建 Docker 镜像调优实践
PS:已经在生产实践中验证,解决在生产环境下,网速带宽小,每次推拉镜像影响线上服务问题,按本文方式构建镜像,除了第一次拉取.推送.构建镜像慢,第二.三-次都是几百K大小传输,速度非常快,构建.打包.推 ...
- 【Docker】Maven打包SpringBoot项目成Docker镜像并上传到Harbor仓库(Eclipse、STS、IDEA、Maven通用)
写在前面 最近,在研究如何使用Maven将SpringBoot项目打包成Docker镜像并发布到Harbor仓库,网上翻阅了很多博客和资料,发现大部分都是在复制粘贴别人的东西,没有经过实践的检验,根本 ...
- 将php项目打包docker镜像
简介:有时候我们需要将php的项目打包成docker镜像,这里介绍下 思路:我们php和apache结合一个镜像实现php项目的访问,mysql是一个单独的镜像 步骤: 1.首先我们在本地测试好自己的 ...
- maven将自己的springboot项目打包成jar包后,作为工具包引入其他项目,找不到jar中的类
将springboot项目打包成jar包,作为工具包导入项目后,找不到jar中的类. 原因是:springboot项目使用了自动的打包插件. 原先的插件配置: <build> <pl ...
- 【Docker】(5)---springCloud注册中心打包Docker镜像
[Docker](5)---springCloud注册中心打包Docker镜像 上一篇文章讲了将镜像推送到远处私有仓库,然后再从私有仓库拉取该镜像的过程.而这里的镜像是直接从Docker拉取的. 所以 ...
- Jenkins把GitHub项目做成Docker镜像
本文是<Jenkins流水线(pipeline)实战>系列的第三篇,前面已对Jenkins流水线有了基本认识,也试过从GitHub下载pipeline脚本并执行,今天的实战是编写一段pip ...
- 将spring cloud打包docker镜像
简介:用spring cloud构建微服务后,微服务肯定要docker镜像化然后用rancher等可视化工具管理,这就是走完了一套基本的流程,现在简单介绍下 环境:两台centos7.x的服务器,一台 ...
- SpringBoot 项目打包后运行报 org.apache.ibatis.binding.BindingException
今天把本地的一个SpringBoot项目打包扔到Linux服务器上,启动执行,接口一访问就报错,但是在本地Eclipse中启动执行不报错,错误如下: org.apache.ibatis.binding ...
随机推荐
- A Simple Math Problem 矩阵打水题
A Simple Math Problem Lele now is thinking about a simple function f(x).If x < 10 f(x) = x.If x & ...
- @Valid 注解的使用
限制 说明 @Null 限制只能为null @NotNull 限制必须不为null @AssertFalse 限制必须为false @AssertTrue 限制必须为true @DecimalMax( ...
- shell运维习题训练
注:初学shell,以下为本人自己写的答案,如果有更好的,请指教! 1. 求2个数之和: 2. 计算1-100的和 3. 将一目录下所有的文件的扩展名改为bak 4.编译并执行当前目录下的所有.c文件 ...
- Java+Selenium3.3.1环境搭建
一.背景和目的 selenium从2.0开始,加入了webdriver,实际上,我们说的selenium自动化测试,大部分情况都是在使用webdriver的API.现在去Selenium官网,发现最新 ...
- 「AGC034E」 Complete Compress
「AGC034E」 Complete Compress 显然可以枚举根. 然后把某两棵棋子同时往深度浅的方向提,即对不存在祖先关系的两个棋子进行操作. 如果能到达那么就更新答案. 问题转化为如何判定能 ...
- 测试管理工具 - Tuleap部署和安装使用教程
安装 通过CentOS的安装,非常简单,命令直接为pip install tuleap 部署 登录管理员权限 登录名为中文名拼音,如wuweiping. 设置的默认密码为12345678,也可以进入配 ...
- C语言:进制转化
16进制数4321转10进制:原来方法 =4*16^3+3*16^2+2*16^1+1*16^0 =4*16^3+3*16^2+2*16^1+1 =16*(4*16^2+3*16^1+2)+1 =16 ...
- C语言:统计字符个数及种类
#include <stdio.h> int main(){ char c; //用户输入的字符 int shu=0;//字符总数 int letters=0, // 字母数目 space ...
- [003] - JavaSE面试题(三):JavaSE语法(1)
第一期:Java面试 - 100题,梳理各大网站优秀面试题.大家可以跟着我一起来刷刷Java理论知识 [003] - JavaSE面试题(三):JavaSE语法(1) 第1问:& 和 & ...
- 前端开发入门到进阶第三集【sublime 的package control ——install package报错】
参考:https://www.cnblogs.com/ae6623/p/5338049.html,解决2帮我解决问题. 解决Sublime包管理package control 报错 There are ...