V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
TechShrimp
V2EX  ›  Docker

使用 Github Action 将 DockerHub 镜像转存到阿里云私有仓库,供国内服务器使用,免费易用

  •  1
     
  •   TechShrimp · 10 天前 · 1428 次点击

    Docker Images Pusher

    使用 Github Action 将 DockerHub 镜像转存到阿里云私有仓库,供国内服务器使用,免费易用

    视频教程: https://www.bilibili.com/video/BV1Zn4y19743/

    项目地址: https://github.com/tech-shrimp/docker_image_pusher

    使用方式

    配置阿里云

    登录阿里云容器镜像服务
    https://cr.console.aliyun.com/
    启用个人实例,创建一个命名空间(ALIYUN_NAME_SPACE

    访问凭证–>获取环境变量 用户名(ALIYUN_REGISTRY_USER)
    密码(ALIYUN_REGISTRY_PASSWORD)
    仓库地址(ALIYUN_REGISTRY

    Fork 本项目

    Fork 项目 https://github.com/tech-shrimp/docker_image_pusher

    进入您自己的项目,点击 Action ,启用 Github Action 功能 配置环境变量,进入 Settings->Secret and variables->Actions->New Repository secret 将上一步的 ALIYUN_NAME_SPACE ,ALIYUN_REGISTRY_USER ,ALIYUN_REGISTRY_PASSWORD ,ALIYUN_REGISTRY 的值配置成环境变量

    添加镜像

    打开 images.txt 文件,添加你想要的镜像,可以带 tag ,也可以不用(默认 latest ) 文件提交后自动进入 Github Action 构建

    使用镜像

    回到阿里云,镜像仓库,点击任意镜像,可查看镜像状态。(可以改成公开,拉取镜像免登录)

    在国内服务器 pull 镜像:

    docker pull registry.cn-hangzhou.aliyuncs.com/shrimp-images/alpine
    

    registry.cn-hangzhou.aliyuncs.com 即 ALIYUN_REGISTRY
    shrimp-images 即 ALIYUN_NAME_SPACE
    alpine 即 images.txt 里面填的镜像

    5 条回复    2024-06-15 13:24:21 +08:00
    0o0O0o0O0o
        1
    0o0O0o0O0o  
       10 天前 via iPhone
    Jokesy
        2
    Jokesy  
       10 天前
    方案很好,受教了。
    ayanamist
        3
    ayanamist  
       10 天前
    果然是 pull+push 的方案,multiarch 镜像全毁,去了解下怎么用 skopeo 或 crane 吧
    brucewsl
        4
    brucewsl  
       5 天前
    skopeo 通过,参考这个 https://www.bilibili.com/read/cv35192993/
    srwxyz
        5
    srwxyz  
       4 天前 via iPhone
    技术能力都是逼出来的😂
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1051 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 19:19 · PVG 03:19 · LAX 12:19 · JFK 15:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.