Git Product home page Git Product logo

docker-registry-cache's Introduction

docker-registry-cache

This is a pull-through docker private registry cache implemented using a Squid HTTP proxy.

WARNING: This only works with the modern docker registry API (v2+). This will not work with docker registries that use the legacy v1 API.

What is this useful for?

Bottom line, it's a HTTP cache.

  • Data center A contains your private registry, and DC B is connected to it over a slow link. Run an instance of this cache on DC B's network, and anytime you pull from it the second time will be significantly faster since you don't have to traverse that slow link as much!
  • I'm sure there are other usecases..

Requirements

You must have docker installed. You must create an SSL certificate and key for your proxy (out of scope for this guide -- google it yourself).

SSL-enabled squid

You must have an SSL-enabled version of squid. Currently, Ubuntu's squid package is not ssl enabled due to licensing issues. To build your own, do this:

$ build-squid/make.sh

After about 30 minutes or so, you should have a bunch of deb packages in the build-squid directory.

Build the cache server image

First, copy squid.conf.template to squid.conf, and change the variables.

  • {{ docker_host }} is your private docker registry host
  • {{ cache_size }} should be set to the cache size, in MB. According to the squid docs, this should not exceed 80% of the disk. For example, 500000 is 500GB.

Next, build the image:

$ ./build.sh

Setup

  • Create an empty directory for your cache.
  • Create a directory for your SSL certificates, and place them in a directory, with the certificate called 'cert.pem' and the private key called 'key.pem'
$ ./run.sh /path/to/ssl /path/to/cache

The registry will start, and be listening on port 443. It should restart on bootup if your docker daemon is running.

Registry authentication

virtuald#7 added a configuration option to squid that passes basic authentication thru to the remote registry. This should work without any further configuration.

It is unknown if other authentication schemes will work with this cache. Feel free to try it out and leave a note with what you find out!

Using the cache

Once the registry cache starts, you pull from it like you would pull from a normal docker registry -- but you pull from the cache hostname, not your original private registry hostname!

$ docker pull CACHE_HOST/foo/bar:latest

Bugs

I'm sure this isn't ideal, but it seems to work. Submit issues and PRs!

License

The contents of this repository are available under the Apache v2 license.

Author

Dustin Spicuzza ([email protected])

docker-registry-cache's People

Contributors

virtuald avatar tehlers320 avatar hulu1522 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.