docker-maven-plugin 完全免Dockerfile 文件
2016-11-25 15:57
127 查看
# 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>
Mvnen :
构建镜像
mvn clean package docker:build
构建镜像并且推送到镜像表
mvn clean package docker:build -DpushImage
建议
如果自己或公司的 docker镜像仓库 ${docker.image.prefix} 设置为自己的 自己的名称 后续上传的时候 就不需要 改名称 了
如果自己不想搭建 公司也没有 但是想 可以随时获取的 可以使用 阿里云的 docker 镜像管理
实例 GitHub https://github.com/atliwen/DockerSpringBootPlugin
使用私有 docker 镜像仓库
注意:
在子Maven 项目中 写 定义 镜像名称 和项目名称
登录私有镜像仓库的配置
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 文件
- 第4章 Maven插件读取DockerFile文件构造镜像
- 在ASP.NET中实现多文件上传(三)---jQuery Multiple File Upload Plugin
- 使用yuicompressor-maven-plugin压缩js及css文件
- ajaxFileUpload plugin上传文件 chrome、Firefox中出现SyntaxError:unexpected token <
- Maven使用yuicompressor-maven-plugin打包压缩css、js文件
- maven-jetty-plugin保存文件报错:请求的操作无法在使用用户映射区域打开的文件上执行
- TekNote #1: 在Mac(Snow Leopard)下,用Maven运行测试(mvn test)时,DBUnit 读文件的编码问题(file.encoding)
- Maven profile结合Maven AntRun Plugin实现不同环境配置文件分离打包
- 使用maven的maven-assembly-plugin将jar包依赖打包到一个jar文件
- Create a fat Jar file – Maven Assembly Plugin
- 使用Maven插件maven-dependency-plugin拷贝所有依赖的jar和pom文件
- Jmeter-maven-plugin高级配置之压测结果文件格式
- Dockerfile文件说明
- 使用maven的maven-assembly-plugin将jar包依赖打包到一个jar文件中
- 彻底摆脱配置文件 八(使用maven-zkcu-plugin灵活控制zkconfigutil)
- build-helper-maven-plugin 配置多 source resource 文件
- jetty-maven-plugin 热加载静态文件
- 使用coffeescript-maven-plugin,实时监控coffee文件的编译,只需一步配置
- ajaxFileUpload plugin上传文件 chrome、Firefox中出现SyntaxError:unexpected token <