Giter Site home page Giter Site logo

hub-mirror's Introduction

hub-mirror

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

使用

1. 白嫖我的,点个 Star ,直接提交 issues

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

限制:每次提交最多 11 个镜像地址

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

2. 自己动手,Fork 本项目,开启 issues 并绑定你自己的 Docker 账号

开启 Settings-Options-Features 中的 Issues 功能

Settings-Secrets 新建 DOCKERHUB_USERNAME(你的 Docker 用户名) 和 DOCKERHUB_TOKEN(你的 Docker 密码) 两个 Secrets

Issues-Labels 添加三个 label :hub-mirrorsuccessfailure

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

3. 已有魔法,本地使用

go install github.com/togettoyou/hub-mirror@latest
hub-mirror --username=xxxxxx --password=xxxxxx --content='{ "hub-mirror": ["gcr.io/google-samples/microservices-demo/emailservice:v0.3.5"] }'

教程

教程首发微信公众号:【SuperGopher】,欢迎关注

微信公众号.png

目前常用的 Docker Registry 公开服务有:

  • docker.io :Docker Hub 官方镜像仓库,也是 Docker 默认的仓库

  • gcr.iok8s.gcr.io :谷歌镜像仓库

  • quay.io :Red Hat 镜像仓库

  • ghcr.io :GitHub 镜像仓库

当使用 docker pull 仓库地址/用户名/仓库名:标签 时,会前往对应的仓库地址拉取镜像,标签无声明时默认为 latest, 仓库地址无声明时默认为 docker.io

众所周知的原因,在国内访问这些服务异常的慢,甚至 gcr.ioquay.io 根本无法访问。

解决方案:镜像加速器

针对 Docker Hub ,Docker 官方和国内各大云服务商均提供了 Docker 镜像加速服务。

你只需要简单配置一下(以 Linux 为例):

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["镜像加速器"]
}
EOF

sudo systemctl daemon-reload
sudo service docker restart

便可以通过访问国内镜像加速器来加速 Docker Hub 的镜像下载。

不过这种办法也只能针对 docker.io ,其它的仓库地址并没有真正实际可用的加速器(至少我目前没找到)。

解决方案:用魔法打败魔法

既然无法治本,那治治标还是可以的吧。

若我们使用一台魔法机器从 gcr.ioquay.io 等仓库先把我们无法下载的镜像拉取下来,然后重新上传到 docker.io ,是不是就可以使用 Docker Hub 的镜像加速器下载了。

镜像仓库迁移的功能,我这里采用了 Go Docker SDK ,整体实现也比较简单,参考 main.go

以需要转换的 gcr.io/google-samples/microservices-demo/emailservice:v0.3.5 为例,使用方式:

功能实现了,剩下的就是找台带有魔法的机器了。

GitHub Actions 就是个好选择,我们可以利用提交 issues 来触发镜像仓库迁移的功能。

workflow 的实现参考 hub-mirror.yml

实际的使用效果参考 issues

只要执行最终输出的命令,就可以飞快的使用 Docker Hub 的加速器下载 gcr.ioquay.io 等镜像了。

hub-mirror's People

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.