安装:
1、安装docker
2、设置镜像加速器(这个操作一定要做,不然拉取镜像贼慢)
{ "registry-mirrors": ["https://08jq45ly.mirror.aliyuncs.com"] }
https://cr.console.aliyun.com)。也可以用其他的加速器,比如网易的http://hub-mirror.c.163.com,但速度很慢。
systemctl daemon-reload systemctl restart docker
3、拉取registry镜像
docker pull registry #拉取latest镜像
https://hub.docker.com/_/registry?tab=tags可以查看可用的镜像标签
4、启动私有仓库
docker run -d -p 5000:5000 -v /var/lib/registry:/var/lib/registry --restart always --name registry registry:latest
5、访问地址http://192.168.107.145:5000/v2/_catalog,可查看是否启动成功
验证:
1、重新找台机器当客户端,修改daemon.jons,添加配置:"insecure-registries": ["192.168.107.145:5000"]
{ "registry-mirrors": ["https://08jq45ly.mirror.aliyuncs.com"], "insecure-registries": ["192.168.107.145:5000"] }
Get https://192.168.107.145:5000/v2/: http: server gave HTTP response to HTTPS client
2、拉取一个nginx镜像,并打上标签
docker tag nginx:latest 192.168.107.145:5000/nginx:1.0 docker images
3、推送新生成的镜像
docker push 192.168.107.145:5000/nginx
docker rmi $(docker images -q) // 删除所有镜像 docker pull 192.168.107.145:5000/nginx:1.0
来源:博客园
作者:玄同太子
链接:https://www.cnblogs.com/zhi-leaf/p/11421199.html