凌文龙
3 years ago
2 changed files with 86 additions and 1 deletions
@ -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) |
|||
|
|||
|
|||
|
Loading…
Reference in new issue