You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.4 KiB

迁移镜像仓库到阿里容器镜像服务分几步:
# 创建命名空间
在阿里云容器镜像服务实例列表中创建命名空间,免费的可以创建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)