Docker私有仓库Registry的搭建

系统环境: CentOS 7.2
192.168.11.138:docker仓库
192.168.11.211:客户端

搭建私有仓库

138上下载registry镜像: docker pull registry

下载完之后我们通过该镜像启动一个容器

1 docker run -d -p 5000:5000 --privileged=true -v /opt/registry:/tmp/registry --name=registry registry

-d 在后台执行

-p 端口映射, 开放容器的5000端口

-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)错误

本机上传镜像

1 docker tag ubuntu:latest localhost:5000/ubuntu
2 docker push localhost:5000/ubuntu

查看仓库的镜像

curl http://localhost:5000/v2/_catalog

{"repositories":["ubuntu"]}

curl http://localhost:5000/ubuntu/tags/list

{"name":"ubuntu","tags":["latest"]}

 

然后使用docker pull从我们的私有仓库中获取ubuntu镜像,

1 docker push localhost:5000/ubuntu
2 docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
localhost:5000/ubuntu latest f975c5035748 4 days ago 112MB
registry latest d1fd7d86a825 2 months ago 33.3MB

客户端上传镜像

 

在”/etc/docker/“目录下,创建”daemon.json“文件。在文件中写入:
如果有这个文件就在时面加一条
{ "insecure-registries":["192.168.1.113:5000"] }

 

转载于:https://www.cnblogs.com/minorblog/p/8547474.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值