lakers009 发表于 2017-12-6 06:10:19

maven 的docker插件

  首先你得配置一个带有认证的docker私有仓库。
  本机要安装maven和jdk
  vi pom.xml



<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<imageName>registry.abccase.com:5000/${project.build.finalName}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>docker</dockerDirectory>
<dockerHost>unix:///var/run/docker.sock</dockerHost>
<serverId>docker-registry</serverId>
<registryUrl>https://registry.abccase.com:5000/v2/</registryUrl>
<dockerCertPath>docker</dockerCertPath>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}-swarm.jar</include>
</resource>
</resources>
</configuration>
</plugin>

dockerCertPath把访问docker私有仓库的证书放在此目录下。由于我们这里用了宿主机的docker,
<dockerHost>unix:///var/run/docker.sock</dockerHost> 
所以可以不用加<dockerCertPath>docker</dockerCertPath>
<dockerDirectory>docker</dockerDirectory>Dockerfile文件放在此目录下。
  配置
# cat /usr/local/maven3/conf/settings.xml



    <server>
<id>docker-registry</id>
<username>sa</username>
<password>aks.1reg</password>
<configuration>
<email>zhou@abccase.com</email>
</configuration>
</server>

  -DpushImage 上传镜像
  -DskipTests  跑过测试
# mvn clean package docker:build -DpushImage-DskipTests
  如果pom.xml里没有带版本号,可以用-DdockerImageTags=0.1.1 -DdockerImageTags=latest
  tag版本号再上传:-DpushImageTag=0.1.1 -DpushImageTag=latest
页: [1]
查看完整版本: maven 的docker插件