# DockerSpringBootPlugin

  docker-maven-plugin 完全免Dockerfile 文件

  使用docker-maven-plugin 进行完全免 Dockerfile 文件

  注意 EXPOSE 在spring boot 中不起作用

详细

  https://github.com/spotify/docker-maven-plugin

  

  本机不安装 docker  连接其他主机或虚拟机

   需要添加两个额外配置

      <dockerHost>https://ip:2376</dockerHost>

      <dockerCertPath>证书地址</dockerCertPath>

  这两个地址可以 在 docker 环境变量中查询到  
  如果是 docker-machine 创建的虚拟机 可以同 env 连接的的时候 会显示

  

  
Mvnen :

构建镜像

  mvn clean package docker:build

构建镜像并且推送到镜像表

  mvn clean package docker:build -DpushImage

 <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<!--<dockerDirectory>src/main/docker</dockerDirectory>-->
<baseImage>java:8</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>

  建议

    如果自己或公司的  docker镜像仓库   ${docker.image.prefix} 设置为自己的 自己的名称  后续上传的时候 就不需要 改名称 了

     如果自己不想搭建 公司也没有 但是想 可以随时获取的 可以使用 阿里云的 docker  镜像管理   

实例 GitHub  https://github.com/atliwen/DockerSpringBootPlugin

使用私有 docker 镜像仓库

<properties>
<docker.maintainer>统一Manven 版本依赖</docker.maintainer>
<docker.imageName>parent</docker.imageName>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId> <configuration>
<serverId>docker-hub</serverId>
<registryUrl>https://10.10.6.50:5000</registryUrl>
<dockerHost>https://10.10.12.205:2376</dockerHost>
<dockerCertPath>C:\Users\admin\.docker\machine\machines\manager</dockerCertPath>
<imageName>10.10.6.50:5000/${docker.imageName}:${project.version}</imageName>
<baseImage>java:8</baseImage>
<maintainer>${docker.maintainer}</maintainer>
<volumes>/tmp</volumes>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>

注意:

  

  在子Maven 项目中  写 定义  镜像名称 和项目名称

  

   docker  镜像 TAG  为版本号  <version>0.0.1-SNAPSHOT</version>

  

<properties>
<docker.maintainer> EDI 订单处理服务</docker.maintainer>
<docker.imageName>dj-atliwen-ediwebapi</docker.imageName>
</properties>

  登录私有镜像仓库的配置

 <serverId>docker-hub</serverId>
<registryUrl>https://10.10.6.50:5000</registryUrl>
serverId 是Maven 中的配置   配置  Maven  settings.xml 中 server 节点
<servers>
<server>
<id>docker-hub</id>
<username>foo</username>
<password>secret-password</password>
<configuration>
<email>foo@foo.bar</email>
</configuration>
</server>
</servers> // email 也是必须填写的

  

docker-maven-plugin 完全免Dockerfile 文件的更多相关文章

  1. Docker学习(六)——Dockerfile文件详解

    Docker学习(六)--Dockerfile文件详解 一.环境介绍 1.Dockerfile中所用的所有文件一定要和Dockerfile文件在同一级父目录下,可以为Dockerfile父目录的子目录 ...

  2. 【Docker】(10)---详细说说 Dockerfile文件

    一.基础概念 1.基本概念 Dockerfile 是一个文本文件,其内包含了一条条的指令,每一条指令构建一层,因此每一条指令的内容,就是描述该层应当如何构建.有了 Dockerfile,当我们需要定制 ...

  3. 『现学现忘』Docker基础 — 34、DockerFile文件详解

    目录 1.DockerFile文件说明 2.Dockerfile构建过程解析 (1)Docker容器构建三步骤 (2)Dockerfile文件的基本结构 (3)Dockerfile注意事项 (4)Do ...

  4. Docker学习计划三:Dockerfile 使用

    我们使用 Dockerfile 定义镜像,依赖镜像来运行容器,因此 Dockerfile 是镜像和容器的关键,Dockerfile 可以非常容易的定义镜像内容 首先通过一张图来了解 Docker 镜像 ...

  5. [Linux] 编写Dockerfile文件自动构建镜像

    Dockerfile是一个文本文件,按顺序包含构建给定镜像所需的所有命令Docker通过读取Dockerfile中的指令自动构建图像 . Dockerfile遵循特定的格式和指令集,您可以在Docke ...

  6. 【Docker】(6)---Dockerfile文件

    springboot项目打包镜像中的Dockerfile文件 在讲Dockerfile文件之前应该先讲下maven的一个插件叫:dockerfile-maven-plugin.他们是组合一起用的 一. ...

  7. Docker(十)-Docker创建DockerFile文件

    制作Docker image 有两种方式: 使用 Docker container,直接构建容器,再导出成 image 使用. 是使用 Dockerfile,将所有动作写在文件中,再 build 成 ...

  8. ASP.NET CORE做的网站运行在docker上(不用dockerfile文件部署)

    按网上的做法用dockerfile文件是可以弄得出来的,http://www.docker.org.cn/article/119.html, 不过我想把网站文件放在外面硬盘目录,再映射进去,这样只要在 ...

  9. Docker定制容器镜像(利用Dockerfile文件)

    1.创建Dockerfile文件 新建一个目录,在里面新建一个dockerfile文件(新建一个的目录,主要是为了和以防和其它dockerfile混乱 ) [root@docker01 myfiles ...

随机推荐

  1. Android深入四大组件(六)Service的启动过程

    前言 此前我用较长的篇幅来介绍Android应用程序的启动过程(根Activity的启动过程),这一篇我们接着来分析Service的启动过程.建议阅读此篇文章前,请先阅读Android深入四大组件(一 ...

  2. linux 服务器 keras 深度学习环境搭建

    感慨: 程序跑不起来,都是环境问题. 1. 安装Anaconda https://blog.csdn.net/gdkyxy2013/article/details/79463859 2. 在 Anac ...

  3. kettle使用命令行传入数据库链接参数(ip、数据库、端口、用户、密码)执行job时子转换失败。

    使用cmd 传参数执行 kettle job 遇到错误: 错误原因,无法找到文件.... 原来使用,通过目录指定转换,好处是:当以文件资源库保存时,可以直接将文件夹复制走,直接运行就可以,不需要单独针 ...

  4. 期初付年金(annuity-due)

    含义:在 n 个时期,每个时期初付款1元. ——期初付年金的现值因子 ——期初付年金的积累值因子 关系: 二.期初付年金和期末付年金的关系

  5. Android Proguard使用技巧

    1.混淆后解码 ProGuard运行结束后,输出以下文件: dump.txt :描述.apk文件中所有类文件间的内部结构 mapping.txt:列出了原始的类,方法和字段名与混淆后代码间的映射.这个 ...

  6. iOS自动化-iOS录屏xrecord及解决iPhone设备不显示的问题

    github地址:https://github.com/WPO-Foundation/xrecord 安装方法: git clone https://github.com/WPO-Foundation ...

  7. codeforces 666C Codeword

    codeforces 666C Codeword 题意 q个询问,一种询问是给你一个字符串,还有一种是问长度为n的,包含当前字符串为子序列的字符串有多少个. 题解 容易写出式子,但是不好化简. 观察一 ...

  8. Scala 经典的模式匹配和尾递归

    Scala 经典的模式匹配和尾递归 package io import java.io.{BufferedWriter, File, FileWriter} import java.text.Simp ...

  9. Counting swaps

    Counting swaps 给你一个1-n的排列,问用最少的交换次数使之变为递增排列的方案数\(mod\ 10^9+7\),1 ≤ n ≤ 10^5. 解 显然最少的交换次数不定,还得需要找到最小交 ...

  10. 5、Spring-Cloud-声明式调用 Feign(上)

    5.1.写一个 Feign 害户端 新建项目: 依赖: <dependency> <groupId>org.springframework.boot</groupId&g ...