GitHub Action自动化同步Docker Hub镜像至阿里云(ARM/x86全适配
利用GitHub+阿里云解决Docker镜像无法拉取
要求:
首先要有GitHub账号和阿里云账号(不需要去购买任何服务)
GitHub登不上去的话使用下面这个地址(国内镜像)
kk使用大神开源的项目
https:///tech-shrimp/docker_image_pusher一、阿里云创建镜像仓库
1.1、登录阿里云容器镜像服务
https://cr.console.aliyun.com/

1.2、创建个人实例
启用个人实例,创建一个命名空间(ALIYUN_NAME_SPACE)


1.3、配置密码

####
1.4、创建命名空间

然后选择本地仓库即可

访问凭证–>获取环境变量 用户名(ALIYUN_REGISTRY_USER) 密码(ALIYUN_REGISTRY_PASSWORD) 仓库地址(ALIYUN_REGISTRY)
二、GitHub配置
2.1、登录GitHub进入docker_image_pusher项目
https:///tech-shrimp/docker_image_pusher2.2、Fork项目


2.3、配置阿里云变量



四个变量分别是
命名空间(ALIYUN_NAME_SPACE) 用户名(ALIYUN_REGISTRY_USER) 密码(ALIYUN_REGISTRY_PASSWORD) 仓库地址(ALIYUN_REGISTRY)





三、通过GitHub拉镜像
3.1、拉取第一个arm镜像


试下
打开images.txt文件,添加你想要的镜像 可以加tag,也可以不用(默认latest) 可添加 --platform=xxxxx 的参数指定镜像架构 可使用 /kube-state-metrics/kube-state-metrics 格式指定私库 可使用 #开头作为注释
构建个arm的nginx镜像试试
nginx:1.20.2
#指定arm架构   注释下面默认就是x86的 也可以指定x86
--platform=linux/arm64 xiaoyaliu/alist
#指定x86架构  默认就是 不需要写
#--platform=linux/x86 xiaoyaliu/alist
文件提交后,自动进入Github Action构建,构建完成后将推送到阿里云容器镜像服务。




docker pull /guoguodcn/linux_arm64_alist:latest3.2、使用arm镜像
切换到Linux服务器
root@gateway251:~# docker pull /guoguodcn/linux_arm64_alist:latest
latest: Pulling from guoguodcn/linux_arm64_alist
61254a502902: Pull complete 
4ee6199c4b83: Pull complete 
ddd395eddbe9: Pull complete 
ea31db6a2293: Pull complete 
41437e3d6e7b: Pull complete 
efd98fc3aa66: Pull complete 
147c42bd9556: Pull complete 
a53227c833ca: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:492b52d0e70425def6d1dd004b11b4ef6bea86b5c14c877f1366f46df667bb03
Status: Downloaded newer image for /guoguodcn/linux_arm64_alist:latest
/guoguodcn/linux_arm64_alist:latest可以改个tag进行使用
3.3、拉取x86镜像
拉个tomcat的
编辑images.txt文件

#输入镜像地址:版本
tomcat:8
#指定arm架构   注释下面默认就是x86的 也可以指定x86
#--platform=linux/arm64 xiaoyaliu/alist
#指定x86架构  默认就是 不需要写
#--platform=linux/x86 xiaoyaliu/alist提交
查看

登陆阿里云镜像仓库查看
已经有了tomcat

docker pull /guoguodcn/tomcat:8

3.4、使用x86镜像
切换到Linux服务器拉取下
root@gateway251:~# docker pull /guoguodcn/tomcat:8
8: Pulling from guoguodcn/tomcat
23828d760c7b: Pull complete 
dfc0d9a6855e: Pull complete 
3026e8edc115: Pull complete 
cd470b4ec28d: Pull complete 
6789efe2b2c4: Pull complete 
4a8163f4748d: Pull complete 
065654ac7cb2: Pull complete 
744365692396: Pull complete 
Digest: sha256:a8db74c98a712eb765cdb94908a22a1566df5e1b663095f86bf6986a8c5991a9
Status: Downloaded newer image for /guoguodcn/tomcat:8
/guoguodcn/tomcat:8 
 
                     
            
        













 
                    

 
                 
                    