From 5b2e6f831b1143e095fdbae142df1f213eb0a702 Mon Sep 17 00:00:00 2001 From: dragon Date: Tue, 7 Dec 2021 17:27:41 +0800 Subject: [PATCH] add move2alirepositories.md --- SUMMARY.md | 2 +- devops/move2alirepositories.md | 85 ++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 devops/move2alirepositories.md diff --git a/SUMMARY.md b/SUMMARY.md index 28f513c..097a318 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -1,7 +1,7 @@ # 目录 ## devops - +- [镜像仓库迁移到阿里云容器镜像服务](devops/move2alirepositories.md) - [gitlab-ce 安装和配置优化](devops/gitlab-ce-install.pdf) - [git 入门](devops/git-start.pdf) - [通过共享订阅实现MQTT接收横向扩展](devops/mqtt/通过共享订阅实现MQTT接收横向扩展.md) diff --git a/devops/move2alirepositories.md b/devops/move2alirepositories.md new file mode 100644 index 0000000..e1cc198 --- /dev/null +++ b/devops/move2alirepositories.md @@ -0,0 +1,85 @@ + 迁移镜像仓库到阿里容器镜像服务分几步: + + + +# 创建命名空间 + + + +在阿里云容器镜像服务实例列表中创建命名空间,免费的可以创建3个。 + +`fs-iot` ,`fs-cloud`,`fs-devops` + + + +# 创建访问凭证 + +用户名就是阿里账号 + +设置固定密码:`V9rtCnt$f` + + + +# 构建镜像 + + + +构建镜像要解决的就是授权问题,不能有交互,自动输入密码。 + +通过工具实现 + +```shell +apt update +apt install expect +``` + + + +在 Jenkins home 目录下增加脚本 `login-ali-repository.sh`: + +```bash +#! /usr/bin/expect + +set timeout 3 +spawn docker login registry.cn-hangzhou.aliyuncs.com -u hi50040201@aliyun.com +expect "Password:" +send "V9rtCnt\$f\r" +interact +``` + + + +原来的镜像构建插件不能用 + +使用脚本构建: + + + +比如: + +```shell +docker build -t registry.cn-hangzhou.aliyuncs.com/fs-cloud/anxinyun-api:$IMAGE_VERSION /var/jenkins_home/workspace/anxinyun-web.api/ + +docker push registry.cn-hangzhou.aliyuncs.com/fs-cloud/anxinyun-api:$IMAGE_VERSION +``` + + + + ![](http://resources.lingwenlong.com/note-img/20211207171700.png) + + + +下面构建: + + ![](http://resources.lingwenlong.com/note-img/20211207171814.png) + + ![](http://resources.lingwenlong.com/note-img/20211207171917.png) + + + +构建成功后到 阿里云 容器镜像服务 仓库中查看: + + ![](http://resources.lingwenlong.com/note-img/20211207172101.png) + + +