---(1)基于容器安装运行Registry
[root@hqs ~]# docker pull registry
[root@hqs ~]# docker run -d -p 5000:5000 --restart=always --name myregistry -v /opt/data/registry:/var/lib/registry registry
[root@hqs ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3cac187c798b registry "/entrypoint.sh /etc…" 29 seconds ago Up 28 seconds 0.0.0.0:5000->5000/tcp myregistry
# 验证刚建立的注册中心
[root@hqs ~]# curl http://127.0.0.1:5000/v2/_catalog
{"repositories":[]} # 此结果说明运行正常,注册中心还没有任何镜像
-- (2)将镜像上传到自建的注册中心
# 1.给已有的镜像打标签符合自建注册中心格式
[root@localhost ~]# docker pull hello-world
[root@localhost ~]# docker tag hello-world 127.0.0.1:5000/hello-world:v1
[root@hqs ~]# docker tag hqs2212586/testdocker 127.0.0.1:5000/testdocker:v1
# 2.执行镜像上传
[root@hqs ~]# docker push 127.0.0.1:5000/hello-world:v1
# 3.执行测试
# 查询registry中所有的镜像名称:curl -XGET http://仓库地址:5000/v2/_catalog
[root@localhost ~]# curl http://127.0.0.1:5000/v2/_catalog
{"repositories":["hello-world"]}
# 依据镜像名称查询镜像版本: curl -XGET http://仓库地址:5000/v2/镜像仓库名/tags/list
[root@localhost ~]# curl -XGET http://127.0.0.1:5000/v2/hello-world/tags/list
{"name":"hello-world","tags":["v1"]}
## vi/etc/docker/daemon.json
# 用法:修改daemon文件
{
"insecure-registries":["192.168.130.102:5000"]
}
# 保存后重启docker
systemctl restart docker
[root@localhost ~]# docker pull 192.168.130.102:5000/hello-world:v1
v1: Pulling from hello-world
Digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4
Status: Downloaded newer image for 192.168.130.102:5000/hello-world:v1
192.168.130.102:5000/hello-world:v1
[root@localhost ~]#
自建Docker注册中心
发布时间 2023-06-08 13:45:08作者: 阀财