![ac7fb8d8a68a2d222b760d32d1c41c2e.png](https://i-blog.csdnimg.cn/blog_migrate/d853d6fc6ccdc1e29946d8fec1df8425.jpeg)
- 创建配置文件:config.yml
version
- 启动容器:
local registry: Quick Version
docker run -d -p 5000:5000 --restart always --name my-registry -v /xxx/config.yml:/etc/docker/registry/config.yml registry:2
启动 docker-registry-ui:
docker run -d -p 80:80 joxit/docker-registry-ui
- 上传镜像到私有仓库:
Now, use it from within Docker:
$ docker pull bosybox
$ docker tag ubuntu localhost:5000/bosybox
$ docker push localhost:5000/bosybox
- 然后用浏览访问 http://172.18.25.78:90 ,因为我本地使用虚拟机作的端口转发,80—>90
![9094592d5c44fa58f6c812190d05c4de.png](https://i-blog.csdnimg.cn/blog_migrate/f9c0a32b58df39180b71e03274cd0baa.png)
- 点击展开后查看详情:
![cde8c0bd62ee04571f496a83e16e5994.png](https://i-blog.csdnimg.cn/blog_migrate/954d1e5a924d16187c71c24bdaaf1169.jpeg)
- 如果碰到 push 镜像时报错: "http: server gave HTTP response to HTTPS client"
![250adada2d2f103b550885130440e4de.png](https://i-blog.csdnimg.cn/blog_migrate/86992e1b5d6252dfe966c47d744b8868.png)
出现这问题的原因是:Docker自从1.3.X之后docker registry交互默认使用的是HTTPS,但是搭建私有镜像默认使用的是HTTP服务,所以与私有镜像交互时出现以上错误。
- 解决办法,在docker配置文件中添加选项,如下:
cd /etc/docker/
# cat daemon.json
{
"registry-mirrors": ["https://dockerhub.azk8s.cn", "https://docker.mirrors.ustc.edu.cn"],
"insecure-registries": ["172.18.25.78:5000"],
"max-concurrent-downloads": 10,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"data-root": "/var/lib/docker"
}
- 然后重启docker
systemctl restart docker