Code Monkey home page Code Monkey logo

hub-mirror's Introduction

hub-mirror

使用 docker.io (hub.docker.com) 或其他镜像服务来提供(但不限于) gcr.io、registry.k8s.io、k8s.gcr.io、quay.io、ghcr.io 等国外镜像加速下载服务

为减少重复请求,合理利用资源,建议提前在 issues 中搜索镜像是否已转换过,可以直接复用

示例:issues搜索registry.k8s.io/kube-apiserver:v1.27.4

原理

无法拉取 gcr.io 镜像?用魔法来打败魔法

更多云原生技术可关注微信公众号:【gopher云原生】

开始使用

方案一:白嫖我的,点个 Star ,直接提交 issues ,按照 issue 模板修改内容即可

要求:严格按照模板规范提交,参考: 成功案例

当任务失败时,可以查看失败原因并直接修改 issues 的内容,即可重新触发任务执行

限制:每次提交最多 11 个镜像地址(为啥是11个?因为我的第一次需求刚好要转换11个镜像🤣)

本人 Docker 账号有每日镜像拉取限额,请勿滥用

方案二:自己动手,丰衣足食,Fork 本项目,绑定你自己的 DockerHub 账号或其他镜像服务账号

  1. 绑定账号

    • 如果要使用默认的 hub.docker.com 镜像服务

      Settings-Secrets and variables-Actions 选择 New repository secret 新建 DOCKER_USERNAME(你的 Docker 用户名) 和 DOCKER_TOKEN(你的 Docker 密码) 两个 Secrets

    • 如果需要使用其它镜像服务,例如腾讯云、阿里云等

      Settings-Secrets and variables-Actions 选择 New repository secret 新建 DOCKER_USERNAME(你的其它镜像服务用户名) 和 DOCKER_TOKEN(你的其它镜像服务密码)以及 DOCKER_REPOSITORY 三个 Secrets

      其中 DOCKER_REPOSITORY 配置例子:

      • 腾讯云: ccr.ccs.tencentyun.com/xxxxxx
      • 阿里云: registry.cn-hangzhou.aliyuncs.com/xxxxxx
  2. 在 Fork 的项目中开启 Settings-General-Features 中的 Issues 功能

  3. 在 Fork 的项目中修改 Settings-Actions-General 中的 Workflow permissionsRead and write permissions

  4. Issues-Labels 选择 New label 依次添加三个 label :hub-mirrorsuccessfailure

  5. Actions 里选择 hub-mirror ,在右边 ··· 菜单里选择 Enable Workflow

  6. 在 Fork 的项目中提交 issues

方案三:已有魔法,支持本地使用(好像用不着)

$ go install github.com/togettoyou/hub-mirror@latest
$ hub-mirror --username=xxxxxx --password=xxxxxx --content='{ "hub-mirror": ["hello-world:latest"] }'
# 如果需要使用自定义镜像仓库
$ hub-mirror --username=xxxxxx --password=xxxxxx --repository=registry.cn-hangzhou.aliyuncs.com/xxxxxx --content='{ "hub-mirror": ["hello-world:latest"] }'

方案四:作为库使用(貌似没什么用)

$ go get github.com/togettoyou/hub-mirror@latest
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/togettoyou/hub-mirror/pkg"
)

func main() {
	cli, err := pkg.NewCli(context.Background(), "", "xxx", "xxx", os.Stdout)
	if err != nil {
		panic(err)
	}

	output, err := cli.PullTagPushImage(context.Background(), "hello-world:latest", "")
	if err != nil {
		panic(err)
	}

	fmt.Println(output.Source, " ===> ", output.Target)
}

hub-mirror's People

Contributors

gclm avatar infdahai avatar skyedai910 avatar sowevo avatar togettoyou avatar

hub-mirror's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.