Giter Club home page Giter Club logo

container-mirror's Introduction

项目介绍

本项目用于将Docker HubGoogle Container RegistryQuay中常用的公共container image自动同步至AWS**区的ECR内,使AWS用户能更方便快捷的获取这些常见的容器镜像。

Amazon ECR镜像路径

所有同步至ECR的镜像都放在048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn这一container registry内,ECR镜像路径规则如下

  • Docker Hub (目前只支持docker official images)
    • 原始镜像路径: [library/]repo:tag
    • ECR镜像路径: 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/dockerhub/[library/]repo:tag
  • GCR
    • 原始镜像路径: gcr.io/namespace/repo:tag
    • ECR镜像路径: 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/gcr/namespace/repo:tag
    • 原始镜像路径: k8s.gcr.io/repo:tag
    • ECR镜像路径: 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/gcr/google_containers/repo:tag
  • Quay
    • 原始镜像路径: quay.io/namespace/repo:tag
    • ECR镜像路径: 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/quay/namespace/repo:tag
  • Global ECR
    • 原始镜像路径: 602401143452.dkr.ecr.us-west-2.amazonaws.com/repo:tag
    • ECR镜像路径: 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/amazonecr/repo:tag

海外镜像复制到ECR后的路径转换示例如下:

海外镜像 ECR镜像
ubuntu:1.17.9 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/dockerhub/ubuntu:1.17.9
gcr.io/heptio-images/velero:v1.1.0 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/gcr/heptio-images/velero:v1.1.0
k8s.gcr.io/cluster-autoscaler:v1.2.2 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/gcr/google_containers/cluster-autoscaler:v1.2.2
quay.io/calico/node:v3.7.4 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/quay/calico/node:v3.7.4
602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon-k8s-cni:v1.5.5 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn/amazonecr/amazon-k8s-cni:v1.5.5

使用方法

使用方法帮助文档

  1. 直接修改 kubernetes deployment yaml 文件中的 image 指向本项目 ECR 中相应镜像的路径。
  2. 不方便修改 image 路径,或者想自动替换所有 Kubernetes Pod 中 image 到相应 ECR 路径,可以使用Kubernetes的Mutating admission webhook 实现自动替换。
  3. 利用 Helm Charts 部署应用,并且chart template支持自定义Pod image,可以设置 chart 参数,指向本项目 ECR 中相应镜像的路径。点击查看如何使用示例
  4. 如果您的 kubernetes 集群直接使用 kubectl 部署,且kubectl版本在v1.14或以上,可以使用kustomize 将原始 image 路径指向指向本项目 ECR 中相应镜像的路径。
  5. 直接 修改 ECS/Fargate 的 task defition yaml 文件,用于部署 ECS/Fargate Service和Task。点击查看如何使用示例
  6. Docker 和 docker-compose, 直接修改文件中的 image 指向本项目 ECR 中相应镜像的路径。点击查看示例

增加新的容器镜像

已有镜像列表放在mirrored-images.txt。 如果您需要其他镜像, 请您编辑 required-images.txt ,这将会在您的GitHub账户中 fork 一个新的分支,之后您可以提交PR(pull request)。 后台管理员 Merge 您的PR会触发CodeBuild 去拉取 required-images.txt 中定义的镜像回 ECR 库。 几分钟后,您可以看到图标从in progress变为passing

详细说明请参考增加新的容器镜像帮助文档

自动同步新镜像

required-images-daily.txt中的镜像,会自动同步高于指定tag的新镜像,tag中包含alpha、beta的不同步。目前仅支持Docker Hub。
比如指定kopeio/etcd-manager:3.0.20190930,会自动同步
kopeio/etcd-manager:3.0.20200116
kopeio/etcd-manager:3.0.20200307

ECR登录/docker login

EKS、Kops on EC2用户可直接使用,无需 ECR登录/docker login。 对于docker用户,需要 ECR 登录/docker login 后才能使用。

  1. 确定你执行命令的 IAM user / IAM role 拥有下面权限:
[
    "ecr:GetDownloadUrlForLayer",
    "ecr:BatchGetImage",
    "ecr:GetAuthorizationToken",
    "ecr:BatchCheckLayerAvailability"
]
  1. 对于docker用户,执行 ECR 登录/docker login:
pip install awscli --upgrade --user
aws ecr get-login-password --region cn-northwest-1 | docker login --username AWS --password-stdin 048912060910.dkr.ecr.cn-northwest-1.amazonaws.com.cn

如果AWS CLI版本低于v1.17.10,需运行以下脚本:

aws ecr get-login --region cn-northwest-1 --registry-ids 048912060910 --no-include-email | sh

您也可以使用ecr-credential-helper 完成登录。

container-mirror's People

Contributors

nowfox avatar liangruibupt avatar toreydai avatar superyhee avatar pahud avatar laolongju avatar walkley avatar guoxun19 avatar ixora avatar stevensu1977 avatar

Watchers

James Cloos avatar

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.