一、开放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"]}
本文介绍如何在CentOS 8环境下搭建Docker私有仓库,包括开放端口、配置本地镜像、启动仓库服务、推送及拉取镜像等步骤,并验证仓库的有效性。
8536

被折叠的 条评论
为什么被折叠?



