docker registry私有仓库使用oss存储实现跨网络镜像推送、调用
解决docker私有仓库跨几个网络环境共享的问题,大体结构是各个环境分别部署registry及调度工具如k8s等,各环境registry使用阿里oss服务做为存储共享镜像,其中过程踩坑无数,总结如下。安装Dockeryum install -y yum-utils device-mapper-persistent-data lvm2yum-config-manager --add-repo...
·
解决docker私有仓库跨几个网络环境共享的问题,大体结构是各个环境分别部署registry及调度工具如k8s等,各环境registry使用阿里oss服务做为存储共享镜像,其中过程踩坑无数,总结如下。
完成后整体结构
安装Docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install -y docker-ce
#使用http连接仓库
mkdir -p /etc/docker
vi /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"],
"insecure-registries":["xxx.xxx.xxx.xxx"]
}
mkdir -p /etc/containers
vi /etc/containers/registries.conf
[registries.search]
registries = ['xxx.xxx.xxx.xxx']
[registries.insecure]
registries = ['xxx.xxx.xxx.xxx']
systemctl daemon-reload
systemctl restart docker
安装docker-compose
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
安装私有仓库
docker pull registry
#使用最简单的账号密码验证
mkdir auth
yum install -y httpd-tools
htpasswd -Bbn admin 111111 > auth/passwd
vi docker-compose.yml
registry:
restart: always
image: registry:latest
ports:
- 80:5000
volumes:
- ./auth:/auth
environment:
- REGISTRY_AUTH=htpasswd
- REGISTRY_AUTH_HTPASSWD_REALM=basic-realm
- REGISTRY_AUTH_HTPASSWD_PATH=/auth/passwd
- REGISTRY_STORAGE=oss
- REGISTRY_STORAGE_OSS_ACCESSKEYID=xxxx
- REGISTRY_STORAGE_OSS_ACCESSKEYSECRET=xxxx
- REGISTRY_STORAGE_OSS_REGION=oss-cn-hangzhou-internal
- REGISTRY_STORAGE_OSS_BUCKET=xxxx
- REGISTRY_STORAGE_DELETE_ENABLED=true
#启停命令
docker-compose up -d
docker-compose down
docker-compose restart
#打标签及上传镜像
docker login xxx.xxx.xxx.xxx
docker tag rancher/healthcheck:v0.3.8 xxx.xxx.xxx.xxx/export/healthcheck:hari-test2.0
docker push xxx.xxx.xxx.xxx/export/healthcheck:hari-test2.0
#查询镜像
curl -u admin:111111-X GET http://xxx.xxx.xxx.xxx/v2/_catalog
#删除镜像
curl -u admin:111111-I -X DELETE http://xxx.xxx.xxx.xxx/v2/export/healthcheck/manifests/sha256:push之后的id
其他残余文件可参考官网API参数增加或者手动到oss删除,或者通过ossfs工具,在本地删除oss里的文件。
更多推荐
已为社区贡献7条内容
所有评论(0)