一、拉取registry镜像
docker pull registry
二、运行容器
docker run -d -p 5000:5000 -v /data/dockerhome/registry:/var/lib/registry registry
三、测试
拉取centos镜像
docker pull centos
[root@centos75-1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 75835a67d134 6 months ago 200MB
#必须先将镜像的名称给变成 域名或ip/镜像名
[root@centos75-1 ~]docker tag centos:latest 127.0.0.1:5000/centos:latest
[root@centos75-1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 75835a67d134 6 months ago 200MB
127.0.0.1:5000/centos latest 75835a67d134 6 months ago 200MB
#推送到本地的仓库上
[root@centos75-1 ~]# docker push 127.0.0.1:5000/centos:latest
The push refers to repository [127.0.0.1:5000/centos]
f972d139738d: Pushed
latest: digest: sha256:dc29e2bcceac52af0f01300402f5e756cc8c44a310867f6b94f5f7271d4f3fec size: 529
#查看目录大小
[root@centos75-1 ~]# du -chs /data/dockerhome/registry
72M /data/dockerhome/registry
72M 总用量
#查看镜像
[root@centos75-1 registry]# curl 127.0.0.1:5000/v2/_catalog
{"repositories":["centos"]}
[root@centos75-1 registry]# curl 127.0.0.1:5000/v2/centos/tags/list
{"name":"centos","tags":["latest"]}
(其中centos是iamge的名称)
http://192.168.103.205:5000/v2/_catalog
http://192.168.103.205:5000/v2/centos/tags/list
进入容器
[root@centos75-1 ~]# docker exec -it sleepy_bartik sh
/ #
删除镜像、垃圾回收
registry清理私有镜像
https://blog.csdn.net/qq_35904833/article/details/80807592
参考:
docker 创建本地仓库详解(push/pull)
https://blog.csdn.net/jobbofhe/article/details/84842844