run local registry mirror for docker behind http/https proxy

If you are behind a proxy and want to proxy docker registry or have multiple machines pulling the same images over and over (CI/CD/ML/DL etc..) and just want to cache them locally the following is a good choice.

create a folder docker-registry-local-cache and create docker-compose.yml file as follows and customize it with your env variables.

vi docker-compose.yml

version: "2"
    image: registry:2
      - 5000:5000
      - NO_PROXY="localhost,,"
      - no_proxy="localhost,,"
      - /opt/registry:/var/lib/registry

run the container with

docker-compose up -d

docker logs dockerregistrylocalcache_registry2_1
and you should see the following

time="2018-04-04T23:18:28Z" level=info msg="Registry configured as a proxy cache to" go.version=go1.7.6 version=v2.6.2
time="2018-04-04T23:18:28Z" level=info msg="listening on [::]:5000" go.version=go1.7.6 version=v2.6.2

should output in something similar to this

Next configure your docker client to use this mirror. See this previous post on how to do that.

Once client side is configured, you can pull a image from a remote dockerhub via your local mirror. For example run
docker pull ubuntu:17.10
like you normally would. then run
again to see the following

This should significantly improve the speed of any subsequent pull from the local clients. Hope you someone finds this useful.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.