一步步搭建docker私有仓库并从私有仓库中下载镜像

  • 一步步搭建docker私有仓库
#下载镜像
docker pull registry
#查看镜像 docker images #运行私有仓库,指定端口和数据卷 docker run 
-d -p 5000:5000 -v /opt/data/registry:/tmp/registry docker.io/registry #-d表示后台运行 -p为端口映射 -v为数据卷挂载,宿主机的/opt/data/registry挂载到容器的/tmp/registry下 #访问私有仓库 curl 192.168.222.128:5000/v1/search #给基础镜像打个标签(前提是mysql镜像存在) docker tag mysql 192.168.222.128:5000/mysql
#将镜像提交到私有仓库
docker push
192.168.222.128:5000/mysql
#查看镜像存储目录(宿主机上操作)
tree 
/opt/data/registry/repositories/
  • 从私有仓库中下载镜像
# 修改Docker配置文件
[root@localhost ~]# vim /etc/sysconfig/docker
# 修改此行
OPTIONS='--selinux-enabled --insecure-registry 192.168.122.128:5000'        //添加私有仓库地址
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart  docker.service

  下载镜像

docker pull 192.168.222.128:5000/mysql
  • 此外也可以在浏览器中通过http://ip:端口/v1/search
原文地址:https://www.cnblogs.com/rwxwsblog/p/5436739.html