基于开源image-syncer组件批量迁移容器仓库上华为云
【摘要】 基于开源image-syncer组件将docker镜像批量迁移到华为云SWR容器仓库服务上,支持华为云不同地域的SWR容器仓库互迁,也支持私有容器仓库迁移到SWR服务。
业务在上云过程中会遇到Docker容器批量迁移的需求,下面基于开源image-syncer组件将docker镜像批量迁移到华为云SWR容器仓库服务上,支持华为云不同地域的SWR容器仓库互迁,也支持私有容器仓库迁移到SWR服务。
1、下载image-syncer
我这边用的是鲲鹏服务器是ARM架构的,所以image-syncer版本选择了ARM架构的
wget https://github.com/AliyunContainerService/image-syncer/releases/download/v1.3.1/image-syncer-v1.3.1-linux-arm64.tar.gz
英特尔的X86架构服务器用这个
wget https://github.com/AliyunContainerService/image-syncer/releases/download/v1.3.1/image-syncer-v1.3.1-linux-amd64.tar.gz
2、解压
tar -zxvf image-syncer-v1.3.1-linux-arm64.tar.gz
解压后内容如下:
3、以下举例华为云上不同地域的SWR仓库迁移
3.1、获取SWR源仓库账户
登录SWR控制台,在右上角单击“登录指令”,在弹出的窗口中获取登录指令,如下图所示:
docker login -u cn-south-4@TSD4KF8TQSPSSSSSSS -p 123456784fa31fb24df3fc052bca6388e6de4d5ddc1a7654321 swr.cn-south-1.myhuaweicloud.com
登录指令中,cn-south-4@TSD4KF8TQSPSSSSSSS为username;123456784fa31fb24df3fc052bca6388e6de4d5ddc1a7654321为password;
cn-east-4.myhuaweicloud.com为镜像仓库地址。
3.2、获取SWR目的仓库账户
docker login -u cn-north-4@VQRCDRHSWL8AAAAAAAA -p 7654321c40dbaeddec9154277d709e71a1ca2fc6ab791234567 swr.cn-north-4.myhuaweicloud.com
3.3、创建账户配置文件auto.json
将源仓库及目标仓库认证信息写入,示例如下:
{
"swr.cn-north-4.myhuaweicloud.com": {
"username": "cn-north-4@VQRCDRHSWL8AAAAAAAA",
"password": "7654321c40dbaeddec9154277d709e71a1ca2fc6ab791234567"
},
"swr.cn-south-1.myhuaweicloud.com": {
"username": "cn-south-1@TSD4KF8TQSPSSSSSSS",
"password": "123456784fa31fb24df3fc052bca6388e6de4d5ddc1a7654321"
}
}
3.4、创建同步镜像描述文件images.json
参数解读:swr.cn-south-1.myhuaweicloud.com/image-syncer/openeuler
镜像仓库地址:swr.cn-south-1.myhuaweicloud.com
组织:image-syncer
容器名称:openeuler
左边是源仓库的地址,右边是目的仓库地址
{
"swr.cn-south-1.myhuaweicloud.com/image-syncer/openeuler":"swr.cn-north-4.myhuaweicloud.com/test/openeuler",
"swr.cn-south-1.myhuaweicloud.com/image-syncer/centos":"swr.cn-north-4.myhuaweicloud.com/test/centos",
"swr.cn-south-1.myhuaweicloud.com/image-syncer/debian":"swr.cn-north-4.myhuaweicloud.com/test/debian",
"swr.cn-south-1.myhuaweicloud.com/image-syncer/mariadb":"swr.cn-north-4.myhuaweicloud.com/test/mariadb",
"swr.cn-south-1.myhuaweicloud.com/image-syncer/ubuntu":"swr.cn-north-4.myhuaweicloud.com/test/ubuntu",
"swr.cn-south-1.myhuaweicloud.com/image-syncer/python":"swr.cn-north-4.myhuaweicloud.com/test/python",
"swr.cn-south-1.myhuaweicloud.com/image-syncer/golang":"swr.cn-north-4.myhuaweicloud.com/test/golang",
"swr.cn-south-1.myhuaweicloud.com/image-syncer/redis":"swr.cn-north-4.myhuaweicloud.com/test/redis"
}
3.5、执行如下命令将镜像迁移至SWR。
./image-syncer --auth=./auth.json --images=./images.json --retries=3 --log=./log
image-syncer项目地址:https://github.com/AliyunContainerService/image-syncer
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)