若物理机没有registry镜像,则需下载registry.tar,并将其导入容器为registry镜像。
1、导入仓库镜像
[root@foundation51 ~]# docker load -i registry.tar
[root@foundation51 ~]# docker images registry

Docker搭建仓库-LMLPHP
Docker搭建仓库-LMLPHP

2、开启容器
[root@foundation51 ~]# docker run -d --name registry -p 5000:5000 -v /tmp/registry:/var/lib/registry registry:2.3.1
[root@foundation51 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                    NAMES
67223728c09d        registry:2.3.1      "/bin/registry /et..."   About a minute ago   Up About a minute   0.0.0.0:5000->5000/tcp   registry
3、上传
[root@foundation51 ~]# docker tag rhel7:ssh localhost:5000/rhel7   ##修改镜像的tag
[root@foundation51 ~]# docker push localhost:5000/rhel7  ##将本地镜像推送到私有仓库

4、下载
注意:因为是本机下载,所有删除原有的镜像才能看到效果
[root@foundation51 ~]# docker rmi localhost:5000/rhel7  ##删除本地镜像
[root@foundation51 ~]# docker rmi rhel7:ssh
[root@foundation51 ~]# docker pull localhost:5000/rhel7  ##从私有仓库下载该镜像

Docker搭建仓库-LMLPHP

[root@foundation51 ~]# docker tag localhost:5000/rhel7 rhel7:ssh  ##修改镜像的tag
[root@foundation51 ~]# docker rmi localhost:5000/rhel7

Docker搭建仓库-LMLPHP

12-19 21:15