搭建docker本地镜像仓库

本文介绍如何在CentOS 8环境下搭建Docker私有仓库,包括开放端口、配置本地镜像、启动仓库服务、推送及拉取镜像等步骤,并验证仓库的有效性。

一、开放5000端口并拉取registry镜像

[root@Centos8 php]# docker pull registry            //目前版本为v2

二、配置本地仓库
修改 /etc/docker/daemon.json

{
                "registry-mirrors" : [
                "https://registry.docker-cn.com",
                "https://docker.mirrors.ustc.edu.cn",
                "http://hub-mirror.c.163.com",
                "https://cr.console.aliyun.com/"
                ],
                "insecure-registries" : [
                "192.168.0.105:5000"
                ]
}

重新启动docker服务

[root@Centos8 php]# systemctl restart docker

三、启动本地仓库

[root@Centos8 php]# mkdir /registry
[root@Centos8 php]# docker run -d -p 5000:5000 --restart always --name registry --privileged -v /registry:/var/lib/registry registry:latest

四、为需要上传的镜像打上标签并推送到本地

[root@Centos8 php]# docker tag php:latest 192.168.0.105:5000/php:latest
[root@Centos8 php]# docker push 192.168.0.105:5000/php:latest

五、拉取本地仓库镜像

[root@Centos8 php]# docker pull 192.168.0.105:5000/php:latest

六、浏览本地仓库

[root@Centos8 php]# curl http://localhost:5000/v2/_catalog
{"repositories":["php"]}
[root@Centos8 php]# curl http://localhost:5000/v2/php/tags/list
{"name":"php","tags":["latest"]}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值