docker搭建本地私有仓库,同一局域网可以访问 . docker 版本:windows desktop docker
1、下载 registry 镜像
docker pull registry
2、在 daemon.json 文件中添加私有镜像仓库的地址并重启docker服务
daemon.json 文件位置:
1) windows: C:\Users\用户名\.docker
2) linux : /etc/docker/
{ "builder": { "gc": { "defaultKeepStorage": "20GB", "enabled": true } }, "experimental": false, "features": { "buildkit": true }, "insecure-registries": [ "10.1.24.16:5000" ], "registry-mirrors": [ "https://docker.mirrors.ustc.edu.cn/", "https://registry.docker-cn.com", "http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn", "https://reg-mirror.qiniu.com", "https://dockerhub.azk8s.cn", "https://mirror.ccs.tencentyun.com" ] }
3、创建registry容器并开放端口
docker create -it registry /bin/bash docker run -d -p 5000:5000 -v D:/file/dockerProject/registry/:/var/lib/registry/ --restart=always registry '//-p指定端口,一内一外;-v表示挂载,前者是本机,后者是容器'
查看容器是否启动
docker ps
4、给镜像打标签
docker tag send:v4 10.1.24.16:5000/send4
send:v4是本地仓库名称和版本; 10.1.24.16:5000/send4 上传到私有仓库地址
5、上传到私有仓库
10.1.24.16:5000/send4是私有仓库地址,跟打标签的相同
docker push 10.1.24.16:5000/send4
6、获取私有仓库列表查看是否上传成功
curl -XGET http://10.1.24.16:5000/v2/_catalog '//若成功会返回仓库列表'
7、验证,从私有仓库下载镜像
docker pull 10.1.24.16:5000/send4
再次查看
docker images
注意:
如果在push 或者pull 过程中报 Error response from daemon: Get "https://10.1.24.16:5000/v2/": http: server gave HTTP response to HTTPS client,
请参考:https://www.cnblogs.com/ychun/p/16461092.html
参考:https://blog.csdn.net/m0_51160032/article/details/122544777