docker-5 docker仓库

docker部署环境:CentOS release 6.5 (Final)

Docker配置文件:/etc/sysconfig/docker  重要参数解释:

-H 表示Docker Daemon绑定的地址 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:235

--registry-mirror表示Docker Registry的镜像地址 --register-mirror=--registry-mirror=https://rr8hxwoy.mirror.aliyuncs.com  阿里云的一个加速节点

--selinux-enabled是否开启Selinux    默认开启 --selinux-enabled=true

--bip 表示网桥docker0使用指定CIDR网络地址, --bip=172.17.42.1

1、编辑docker的配置文件,因为我们启动的registry服务不是安全可信赖的。所以我们需要修改docker的配置文件,

[root@docker]# vim /etc/sysconfig/docker

other_args="--insecure-registry=192.168.1.243:5000 -H tcp://0.0.0.0:235 -H unix:///var/run/docker.sock"

2、修改好配置文件之后,重启docker

[root@docker]# /etc/init.d/docker restart

3、获取registry

[root@docker]# docker pull registry

4、启动registry

[root@docker]# docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry registry

[root@docker]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e600f830f51 registry "/entrypoint.sh /etc 13 minutes ago Up 2 seconds 0.0.0.0:5000->5000/tcp drunk_albattani

Registry服务默认会将上传的镜像保存在容器的/var/lib/registry,我们将主机的/opt/registry目录挂载到该目录,即可实现将镜像保存到主机的/opt/registry目录了。

这时在浏览器里面输入:http://IP:5000/v2/

会返回一个{}

5、做tag标签

[root@AY121107032540ded7114 ROOT]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
pt/tomcat_biz       v1                  f56c998ac2f3        37 hours ago        756.3 MB
centos              latest              97cad5e16cb6        6 days ago          196.5 MB
registry            latest              5c929a8b587a        3 weeks ago         33.27 MB
[root@AY121107032540ded7114 ROOT]# docker tag centos:latest 10.116.208.166:5000/test/centos:v1     
[root@AY121107032540ded7114 ROOT]# docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
pt/tomcat_biz                     v1                  f56c998ac2f3        37 hours ago        756.3 MB
centos                            latest              97cad5e16cb6        6 days ago          196.5 MB
10.116.208.166:5000/test/centos   v1                  97cad5e16cb6        6 days ago          196.5 MB
registry                          latest              5c929a8b587a        3 weeks ago         33.27 MB

6、push到registry

[root@AY121107032540ded7114 ROOT]# docker push 10.116.208.166:5000/test/centos:v1
The push refers to a repository [10.116.208.166:5000/test/centos] (len: 1)
97cad5e16cb6: Image already exists 
05fe84bf6d3f: Image already exists 
af0819ed1fac: Image successfully pushed 
3690474eb5b4: Image already exists 
Digest: sha256:31879c6c05e2cb19300a12a685998f4d45f924f48a7d7d215846c9511f40176c

7、打开另外一台服务器,做pull测试

[root@AY121107032540ded7114 ROOT]# docker pull 10.116.208.166:5000/test/centos:v1

到此为止,私有的仓库就搭建好了。

 

posted @ 2016-11-10 00:59  kafeikele  阅读(437)  评论(0编辑  收藏  举报