GOOGLE JIB

原创
2018/07/12 11:55
阅读数 1.7K

GOOGLE新推出的java maven容器构建,这里写一下我的使用过程

官方github: https://github.com/GoogleContainerTools/jib.git

 

1.准备一个自己的docker 私服,我的私服服务器地址是:192.168.232.101

1.1 安装docker服务,并启动

yum install docker -y  

systemctl enable docker  

systemctl start docker 

我这边删除了/etc/sysconfig/docker的insecure

1.2 安装registry

docker pull registry:latest

 

docker run -d -p 5000:5000 --restart=always \

-v /opt/registry-var/:/var/lib/registry/ \

registry:latest

 

在/etc/sysconfig/docker文件中添加一下配置:

ADD_REGISTRY='--insecure-registry 192.168.232.101:5000'  

systemctl restart docker 

 

2.JAVA工程设置

 

<build>
		<plugins>
			
			<plugin>
				<groupId>com.google.cloud.tools</groupId>
				<artifactId>jib-maven-plugin</artifactId>
				<version>0.9.4</version>
				<configuration>
					<from>
						<image>hub.c.163.com/chengyingqi/centos-jdk:latest</image>
						<!--<credHelper>None</credHelper>-->
					</from>
					<!--<to>-->
						<!--<image>hub.c.163.com/chengyingqi/oauth:latest</image>-->
						<!--<credHelper>pass</credHelper>-->
					<!--</to>-->
					<to>
						<image>192.168.232.101:5000/chengyingqi/oauth:1.0</image>
					</to>
					<allowInsecureRegistries>true</allowInsecureRegistries>
				</configuration>
			</plugin>
		</plugins>
	</build>

这里拉取了一个我自己的jdk镜像,并推送到刚刚的docker私服

执行mvn compile

mvn jib:build

 

3.私服查看

[root@localhost ~]# curl -XGET http://192.168.232.101:5000/v2/_catalog
{"repositories":["chengyingqi/oauth"]}
[root@localhost ~]# curl -XGET http://192.168.232.101:5000/v2/chengyingqi/oauth/tags/list
{"name":"chengyingqi/oauth","tags":["1.0"]}
[root@localhost ~]# 

4.从另外一台服务器拉取

[root@localhost chengyingqi]# echo '{ "insecure-registries":["192.168.232.101:5000"] }' > /etc/docker/daemon.json
[root@localhost zsg]# docker pull 192.168.232.101:5000/chengyingqi/oauth:1.0Trying to pull repository 192.168.232.101:5000/chengyingqi/oauth ... 
Get https://192.168.232.101:5000/v1/_ping: http: server gave HTTP response to HTTPS client
[root@localhost chengyingqi]# systemctl restart docker
[root@localhost chengyingqi]# docker pull 192.168.232.101:5000/chengyingqi/oauth:1.0
Trying to pull repository 192.168.232.101:5000/chengyingqi/oauth ... 
1.0: Pulling from 192.168.232.101:5000/chengyingqi/oauth
a3ed95caeb02: Pull complete 
86cd131a32e8: Pull complete 
25faacc49e05: Pull complete 
5e35d10a3eba: Pull complete 
ee5c8e5870ad: Pull complete 
f74e450a7752: Pull complete 
2adecf746b69: Pull complete 
Digest: sha256:a5ce41180f978fa46c6e151f82c21d64b2bff73ea68110b9f9bc593c6269f498
Status: Downloaded newer image for 192.168.232.101:5000/chengyingqi/oauth:1.0

 

 

OK ~谢谢

展开阅读全文
打赏
0
9 收藏
分享
加载中
更多评论
打赏
0 评论
9 收藏
0
分享
返回顶部
顶部