Giter Club home page Giter Club logo

docker-mirror's Introduction

docker-mirror

This project will copy public DockerHub repositories to a private registry.

It's possible to filter by docker tags, tag age and number of latest tags.

Install / Building

  • make sure you got Go 1.10 or newer
    • OSX: brew install go
  • make sure you got godep installed
    • OSX: brew install dep
  • make sure you have CGO enabled
    • export CGO_ENABLED=1
  • clone this repository to $HOME/src/github.com/seatgeek/docker-mirror
  • change your working directory to $HOME/go/src/github.com/seatgeek/docker-mirror
  • run dep ensure -vendor-only to install dependencies
  • run go install to build and install the docker-mirror binary into your $HOME/go/bin/ directory
    • alternative: go build to build the binary and put it in the current working directory

Using

Make sure that your local Docker agent is logged into to ECR (eval $(aws ecr get-login --no-include-email --region us-east-1))

docker-mirror will automatically create the ECR repository on demand, so you do not need to login and do any UI operations in the AWS Console.

docker-mirror will look for your AWS credentials in all the default locations (env, ~/.aws/ and so forth like normal AWS tools do)

Adding new mirror repository

  • add the new repository to the config.yaml file
    • TIP: omit the max_tag_age for the initial sync to mirror all historic tags (match_tag is fine to use in all cases)
  • run PREFIX=${reopsitory_name} docker-mirror to trigger a sync for the specific new repository (you probably don't want to sync all the existing repositories)
  • add the max_tag_age filter to the newly added repository so future syns won't cosider all historic tags

Updating / resync an existing repository

  • run PREFIX=${reopsitory_name} docker-mirror to trigger a sync for the specific repository
    • TIP: Consider if the tags you want to sync fits within the max_tag_age and other filters

Update all repositories

  • run docker-mirror and wait (for a while)

Example config.yaml

---
target:
  # where to copy images to
  registry: ACCOUNT_ID.dkr.REGION.amazonaws.com

  # (optional) prefix all repositories with this name
  # ACCOUNT_ID.dkr.REGION.amazonaws.com/hub/jippi/hashi-ui
  prefix: "hub/"

# what repositories to copy
repositories:
    # will automatically know it's a "library" repository in dockerhub
  - name: elasticsearch
    match_tag: # tags to match, can be specific or glob pattern
      - "5.6.8" # specific tag match
      - "6.*"   # glob patterns will match
    ignore_tag: # tags to never match on (even if its matched by `tag`)
      - "*-alpine" # support both glob or specific strings

  - name: yotpo/resec
    max_tag_age: 8w # only import tags that are 8w or less old

  - name: jippi/hashi-ui
    max_tags: 10 # only copy the 10 latest tags
    match_tag:
      - "v*"

  - name: jippi/go-metadataproxy # import all tags

Environment Variables

Environment Variable Default Description
CONFIG_FILE config.yaml config file to use
DOCKERHUB_USER unset optional user to authenticate to docker hub with
DOCKERHUB_PASSWORD unset optional password to authenticate to docker hub with

docker-mirror's People

Contributors

burdandrei avatar jippi avatar josegonzalez avatar sampointer avatar

Watchers

 avatar  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.