码迷,mamicode.com
首页 > 其他好文 > 详细

docker 私有仓库的创建

时间:2017-02-09 23:35:49      阅读:429      评论:0      收藏:0      [点我收藏+]

标签:imp   ica   ons   cat   nal   support   reg   sea   val   

1, 下载registry镜像

sudo docker pull registry 

 2, 启动镜像

sudo docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry 

参数说明:
-v /opt/registry:/tmp/registry :默认情况下,会将仓库存放于容器内的/tmp/registry目录下,指定本地目录挂载到容器
–privileged=true :CentOS7中的安全模块selinux把权限禁掉了,参数给容器加特权,不加上传镜像会报权限错误(OSError: [Errno 13] Permission denied: ‘/tmp/registry/repositories/liibrary’)或者(Received unexpected HTTP status: 500 Internal Server Error)错误

3, 修改一下镜像的tag

sudo docker tag busybox wenbronk/busybox

4, 将打了tag的image上传

docker push wenbronk/busybox

  注: 此处可能报错, 我的没有

Error: Invalid registry endpoint https://192.168.112.136:5000/v1/: Get https://192.168.112.136:5000/v1/_ping: dial tcp 192.168.112.136:5000: connection refused. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 192.168.112.136:5000` to the daemon‘s arguments. In the case of HTTPS, if you have access to the registry‘s CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.112.136:5000/ca.crt 

 因为Docker从1.3.X之后默认docker registry使用的是https,所以当用docker pull命令下载远程镜像时,如果远程docker registry是非https的时候就会报上面的错误。为了解决这个问题需要在启动docker server时增加启动参数修改docker启动配置文件

vim /etc/sysconfig/docker

 Ubuntu下配置文件地址为:/etc/init/docker.conf),增加启动选项(已有参数的在后面追加),之后重启docker

OPTIONS=--insecure-registry 192.168.0.110:5000    #CentOS 7系统
other_args=--insecure-registry 192.168.0.110:5000 #CentOS 6系统

 

5, 因为Docker从1.3.X之后,与docker registry交互默认使用的是https,而此处搭建的私有仓库只提供http服务 在docker公共仓库下载一个镜像

docker push 192.168.0.110:5000/busybox

 

6, 查询仓库中的镜像

docker search 192.168.0.110:5000

 

docker 私有仓库的创建

标签:imp   ica   ons   cat   nal   support   reg   sea   val   

原文地址:http://www.cnblogs.com/wenbronk/p/6384517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!