#++++++++++++++++++++++++++++++
#docker-registry 私有仓库
#搜索,下载register镜像
docker search registry
docker pull registry
docker images
#创建容器registry
mkdir -p /www/docker/registry
docker run --name registry --restart=always -p 5000:5000
-v /www/docker/registry:/var/lib/registry -d registry
docker ps -l
#镜像仓库地址使用域名
echo '127.0.0.1 hub.test.com'>>/etc/hosts
#修改tag (以hello-world为例)
docker push hello-world
docker tag hello-world hub.test.com:5000/hello-world:1.0
#上传、删除、再下载镜像,删除后能下载成功
docker images
docker push hub.test.com:5000/hello-world:1.0
docker rmi hub.test.com:5000/hello-world:1.0
docker images
docker pull hub.test.com:5000/hello-world:1.0
docker images
#查看仓库镜像
curl hub.test.com:5000/v2/_catalog
#++++++++++++++++++++++++++++++
#registry开启删除
#查看默认配置
docker exec -it registry sh -c 'cat /etc/docker/registry/config.yml'
#开启删除(添加 delete: enabled: true)
docker exec -it registry sh -c "sed -i '/storage:/a delete:' /etc/docker/registry/config.yml"
docker exec -it registry sh -c "sed -i '/delete:/a enabled: true' /etc/docker/registry/config.yml"
#重启
docker restart registry
#查询、删除镜像
#查询镜像
curl <仓库地址>/v2/_catalog
#查询镜像tag(版本)
curl <仓库地址>/v2/<镜像名>/tags/list
#删除镜像API
curl -I -X DELETE "<仓库地址>/v2/<镜像名>/manifests/<镜像digest_hash>"
#获取镜像digest_hash
curl <仓库地址>/v2/<镜像名>/manifests/<tag>
--header "Accept: application/vnd.docker.distribution.manifest.v2+json"
# 为方面使用,写了个shell脚本
#默认查询 -h #帮助 -d #删除
#++++++++++++++++++++++++++++++
#没配置https,非本机,需要配置安全地址才能使用
#docker私有仓库设置(hub.test.com:5000替换为自己的地址)
SetOPTS=" --insecure-registry hub.test.com:5000"
sed -i "s#^ExecStart.*#& $SetOPTS #" /usr/lib/systemd/system/docker.service
grep 'ExecStart' /usr/lib/systemd/system/docker.service
#重启docker
systemctl daemon-reload
systemctl restart docker
#++++++++++++++++++++++++++++++