docker-5 docker仓库
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker-5 docker仓库相关的知识,希望对你有一定的参考价值。
docker部署环境:CentOS release 6.5 (Final)
1、编辑docker的配置文件,因为我们启动的registry服务不是安全可信赖的。所以我们需要修改docker的配置文件,
[[email protected]]# 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
[[email protected]]# /etc/init.d/docker restart
3、获取registry
[[email protected]]# docker pull registry
4、启动registry
[[email protected]]# docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry registry
[[email protected]]# 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标签
[[email protected] 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 [[email protected] ROOT]# docker tag centos:latest 10.116.208.166:5000/test/centos:v1 [[email protected] 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
[[email protected] 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测试
[[email protected] ROOT]# docker push 10.116.208.166:5000/test/centos:v1
到此为止,私有的仓库就搭建好了。
以上是关于docker-5 docker仓库的主要内容,如果未能解决你的问题,请参考以下文章