Docker 搭建Registry私有仓库

Registry 仓库搭建如下

环境准备

主机IP地址
Registry 私有仓库192.168.1.10
测试端192.168.1.20

搭建过程如下
Registry服务端的配置

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum install -y docker    //安装docker
[root@localhost ~]# vim /etc/sysconfig/docker   //修改配置文件
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 192.168.1.10:5000'  //添加一个参数以 --insecure开头的
ADD_REGISTRY='--add-registry 192.168.1.10:5000'  //增加一条这个
[root@localhost ~]# systemctl start docker 
[root@localhost ~]# systemctl enable docker 
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# docker search registry    //查找镜像
[root@localhost ~]# docker pull docker.io/registry   //查找好了以后进行下载操作
[root@localhost /]# docker images     //查询本地镜像库
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
docker.io/registry   latest              c9bd19d022f6        4 years ago         33.3 MB
[root@localhost /]# docker run -itd --name=registry -p 5000:5000 --restart=always docker.io/registry:latest   //然后启动registry仓库即可     
35a2a78923182213d46d85ea9bc1d550f6e39d22dc5cdf049d2fd439375cbc21
[root@localhost /]# docker ps     //查看容器的状况
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                    NAMES
35a2a7892318        docker.io/registry:latest   "/entrypoint.sh /e..."   24 seconds ago      Up 23 seconds       0.0.0.0:5000->5000/tcp   registry
[root@localhost /]# ss -tan | grep 5000
LISTEN     0      128       [::]:5000                  [::]:*   
[root@localhost ~]# docker tag c9bd19d022f6  192.168.1.10:5000/registry:latest    //打标
[root@localhost ~]# docker push     192.168.1.10:5000/registry:latest    //然后上传到私有仓库里面去
The push refers to a repository [192.168.1.10:5000/registry]
9b728062fb6d: Pushed 
481c807467a1: Pushed 
a049b9c716b3: Pushed 
d57f828d06ea: Pushed 
011b303988d2: Pushed 
[root@localhost ~]# curl 192.168.1.10:5000/v2/_catalog   //查询仓库存在的镜像
{"repositories":["registry"]}

我们可以上传一个镜像到仓库里面,然后客户端使用docker pull下载测试
[root@localhost /]# docker images 
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
192.168.1.10:5000/nginx      latest              3f8a4339aadd        2 years ago         108 MB
上传好Nginx镜像进行打包操作
[root@localhost /]# docker push 192.168.1.10:5000/nginx:latest    //上传到registry私有仓库
[root@localhost /]# curl 192.168.1.10:5000/v2/_catalog
{"repositories":["nginx","registry"]}

客户端测试

[root@localhost ~]# yum install -y docker   //安装docker
[root@localhost ~]# vim /etc/docker/daemon.json //编辑该文件,写入如下内容
{
"insecure-registries":["192.168.1.10:5000"] //添加私有仓库的地址
}
~     
[root@localhost ~]# systemctl start docker 
[root@localhost ~]# systemctl enable docker 
[root@localhost ~]# curl 192.168.1.10:5000/v2/_catalog
{"repositories":["nginx","registry"]}
客户端查看registry私有仓库存在的镜像
[root@localhost ~]# docker pull 192.168.1.10:5000/nginx:latest    //然后下载镜像
[root@localhost ~]# docker images     //然后查看下载的镜像
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
192.168.1.10:5000/nginx   latest              3f8a4339aadd        2 years ago         108 MB
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ball-4444

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值